-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scan all versions in multi-version-jar #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,10 +237,13 @@ private static IModule extractModuleFromArchive(File file, Classpath pathEntry, | |
try { | ||
zipFile = new ZipFile(file); | ||
if (release != null) { | ||
String releasePath = "META-INF/versions/" + release + "/" + path; //$NON-NLS-1$ //$NON-NLS-2$ | ||
ZipEntry entry = zipFile.getEntry(releasePath); | ||
if (entry != null) { | ||
path = releasePath; | ||
for (int version = Integer.parseInt(release); version >= 9; version--) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is practically the same code as above. |
||
String releasePath = "META-INF/versions/" + version + "/" + path; //$NON-NLS-1$ //$NON-NLS-2$ | ||
ZipEntry entry = zipFile.getEntry(releasePath); | ||
if (entry != null) { | ||
path = releasePath; | ||
break; | ||
} | ||
} | ||
} | ||
ClassFileReader reader = ClassFileReader.read(zipFile, path); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,13 +125,18 @@ IModule initializeModule() { | |
ZipFile file = null; | ||
try { | ||
file = new ZipFile(this.zipFilename); | ||
String releasePath = "META-INF/versions/" + this.compliance + '/' + IModule.MODULE_INFO_CLASS; //$NON-NLS-1$ | ||
ClassFileReader classfile = null; | ||
try { | ||
classfile = ClassFileReader.read(file, releasePath); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
// move on to the default | ||
for (int version = Integer.parseInt(this.compliance); version >= 9; version--) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here, we search for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why It's being done in ClasspathJar instead of org.eclipse.jdt.internal.core.builder.ClasspathMultiReleaseJar ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jarthana Do you mean, why I have made this change or why this code is here at all? IMHO it sounds logical, if this is handled in ClasspathMultiReleaseJar as it does not require to have duplicate code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just wondering about having this in the super class ClasspathJar but in case of the compiler.batch package, you have made it in the subclass ClasspathMultiReleaseJar. Haven't looked at the code in detail, but IIRC, we had similar code and hierarchy in both the compiler.batch and core.builder packages. |
||
String releasePath = "META-INF/versions/" + version + '/' + IModule.MODULE_INFO_CLASS; //$NON-NLS-1$ | ||
try { | ||
classfile = ClassFileReader.read(file, releasePath); | ||
if (classfile != null) { | ||
break; | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
// move on to the next or default | ||
} | ||
} | ||
if (classfile == null) { | ||
classfile = ClassFileReader.read(file, IModule.MODULE_INFO_CLASS); // FIXME: use jar cache | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to
https://docs.oracle.com/javase/10/docs/specs/jar/jar.html#multi-release-jar-files
all versions down to 9 have to be checked.
this.compliance
should be always a major version accroding to the spec, soparseInt
should workThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it would be good to parse the compliance only once (same below) and cache it in a field?