Browse Source

Fix invalid manifests leading to "Could not find or load main class"

WARNING: Please avoid line breaks in manifest values! They are passed on
like this: Assembly Plugin -> Plexus Archiver -> JRE java.util.jar
.Manifest.write(OutputStream).

The JRE Manifest class inserts hard line breaks always after 72
characters, no matter if those 72 characters contain line feeds, tabs or
spaces. Hence, it can happen that unwanted blank lines end up in the
middle of a manifest section, making the manifest invalid. Calls like
e.g. 'java -cp aspectjtools.jar org.aspectj.tools.ajc.Main' can then
fail with the absolutely unexpected error 'Could not find or load main
class org.aspectj.tools.ajc.Main'.

In IntelliJ IDEA you can deactivate wrapping text inside XML tags like
this: "File | Settings | Editor | Code Style | XML | Wrap text -> off"

The problem occurs in Maven Assembly in versions higher than 2.2. More
exactly, it occurs in Plexus Archiver after in more recent versions it
switched to using the JRE Manifest class.

TODO 1: Either add a test step in phase 'verify' doing something like
this:

new Manifest(new FileInputStream("MANIFEST.MF"));

This would lead to "IOException: invalid header field (line xy)" in case
of an invalid manifest file.

TODO 2: Or file a JRE bug at Oracle or OpenJDK, wherever appropriate.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/java16-add-opens
Alexander Kriegisch 3 years ago
parent
commit
0b182d6067
4 changed files with 56 additions and 12 deletions
  1. 14
    3
      aspectjmatcher/pom.xml
  2. 14
    3
      aspectjrt/pom.xml
  3. 14
    3
      aspectjtools/pom.xml
  4. 14
    3
      aspectjweaver/pom.xml

+ 14
- 3
aspectjmatcher/pom.xml View File

@@ -98,9 +98,20 @@

<Bundle-Name>AspectJ Matcher</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation,
2002 Palo Alto Research Center, Incorporated (PARC),
2003-2020 Contributors. All Rights Reserved</Bundle-Copyright>
<!--
WARNING: Please avoid line breaks in manifest values! They are passed on like this:
Assembly Plugin -> Plexus Archiver -> JRE java.util.jar.Manifest.write(OutputStream).

The JRE Manifest class inserts hard line breaks always after 72 characters, no matter if those
72 characters contain line feeds, tabs or spaces. Hence, it can happen that unwanted blank lines
end up in the middle of a manifest section, making the manifest invalid. Calls like e.g.
'java -cp aspectjtools.jar org.aspectj.tools.ajc.Main' can then fail with the absolutely
unexpected error 'Could not find or load main class org.aspectj.tools.ajc.Main'.

In IntelliJ IDEA you can deactivate wrapping text inside XML tags like this:
File | Settings | Editor | Code Style | XML | Wrap text -> deactivate
-->
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation, 2002 Palo Alto Research Center, Incorporated (PARC), 2003-2020 Contributors. All Rights Reserved</Bundle-Copyright>
</manifestEntries>
</manifestSection>
</manifestSections>

+ 14
- 3
aspectjrt/pom.xml View File

@@ -74,9 +74,20 @@

<Bundle-Name>AspectJ Runtime</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation,
2002 Palo Alto Research Center, Incorporated (PARC),
2003-2019 Contributors. All Rights Reserved</Bundle-Copyright>
<!--
WARNING: Please avoid line breaks in manifest values! They are passed on like this:
Assembly Plugin -> Plexus Archiver -> JRE java.util.jar.Manifest.write(OutputStream).

The JRE Manifest class inserts hard line breaks always after 72 characters, no matter if those
72 characters contain line feeds, tabs or spaces. Hence, it can happen that unwanted blank lines
end up in the middle of a manifest section, making the manifest invalid. Calls like e.g.
'java -cp aspectjtools.jar org.aspectj.tools.ajc.Main' can then fail with the absolutely
unexpected error 'Could not find or load main class org.aspectj.tools.ajc.Main'.

In IntelliJ IDEA you can deactivate wrapping text inside XML tags like this:
File | Settings | Editor | Code Style | XML | Wrap text -> deactivate
-->
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation, 2002 Palo Alto Research Center, Incorporated (PARC), 2003-2020 Contributors. All Rights Reserved</Bundle-Copyright>
</manifestEntries>
</manifestSection>
</manifestSections>

+ 14
- 3
aspectjtools/pom.xml View File

@@ -130,9 +130,20 @@

<Bundle-Name>AspectJ Tools</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation,
2002 Palo Alto Research Center, Incorporated (PARC),
2003-2019 Contributors. All Rights Reserved</Bundle-Copyright>
<!--
WARNING: Please avoid line breaks in manifest values! They are passed on like this:
Assembly Plugin -> Plexus Archiver -> JRE java.util.jar.Manifest.write(OutputStream).

The JRE Manifest class inserts hard line breaks always after 72 characters, no matter if those
72 characters contain line feeds, tabs or spaces. Hence, it can happen that unwanted blank lines
end up in the middle of a manifest section, making the manifest invalid. Calls like e.g.
'java -cp aspectjtools.jar org.aspectj.tools.ajc.Main' can then fail with the absolutely
unexpected error 'Could not find or load main class org.aspectj.tools.ajc.Main'.

In IntelliJ IDEA you can deactivate wrapping text inside XML tags like this:
File | Settings | Editor | Code Style | XML | Wrap text -> deactivate
-->
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation, 2002 Palo Alto Research Center, Incorporated (PARC), 2003-2020 Contributors. All Rights Reserved</Bundle-Copyright>
</manifestEntries>
</manifestSection>
</manifestSections>

+ 14
- 3
aspectjweaver/pom.xml View File

@@ -102,9 +102,20 @@

<Bundle-Name>AspectJ Weaver</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation,
2002 Palo Alto Research Center, Incorporated (PARC),
2003-2019 Contributors. All Rights Reserved</Bundle-Copyright>
<!--
WARNING: Please avoid line breaks in manifest values! They are passed on like this:
Assembly Plugin -> Plexus Archiver -> JRE java.util.jar.Manifest.write(OutputStream).

The JRE Manifest class inserts hard line breaks always after 72 characters, no matter if those
72 characters contain line feeds, tabs or spaces. Hence, it can happen that unwanted blank lines
end up in the middle of a manifest section, making the manifest invalid. Calls like e.g.
'java -cp aspectjtools.jar org.aspectj.tools.ajc.Main' can then fail with the absolutely
unexpected error 'Could not find or load main class org.aspectj.tools.ajc.Main'.

In IntelliJ IDEA you can deactivate wrapping text inside XML tags like this:
File | Settings | Editor | Code Style | XML | Wrap text -> deactivate
-->
<Bundle-Copyright>(C) Copyright 1999-2001 Xerox Corporation, 2002 Palo Alto Research Center, Incorporated (PARC), 2003-2020 Contributors. All Rights Reserved</Bundle-Copyright>
</manifestEntries>
</manifestSection>
</manifestSections>

Loading…
Cancel
Save