-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support Java 9 class file format #406
Conversation
Although I don't think the format has changed we need a version of ASM which accepts the new header. The last time ASM was released around the same time when Java 8 was released. The reason is that OpenJDK releases the final spec at the same time as the JDK :-/ |
@marchof according to my observations the list of changes in https://bugs.openjdk.java.net/browse/JDK-8148785 is exhaustive, and so indeed for ASM the only change is to accept newer version as in https://bugs.openjdk.java.net/browse/JDK-8151858 However I'm wondering how we can keep on testing classes compiled with JDK 9 EA when javac from one of the next builds will start producing newer version. |
This change is not in jdk-9+118 , but I guess will be in jdk-9+119. |
What are the options?
Also we need to add a new entry in ContentTypeDetector.determineType(). If you agree on solution 2 I can prepare a patch for this. What I would do is to create a internal Also in any case we should try option 3 in parallel. |
@marchof actually I already have patch for option 2, but need to test it on updated javac. |
0c24111
to
c3697d8
Compare
@marchof could you please review? Note that this is not sufficient to be able to build JaCoCo with compilation into new class files, because maven-shade-plugin also requires update. However this allows JaCoCo to work properly with new class files - I added integration test (instrumentation with agent + report generation on new class files) and tested with local dev build of latest OpenJDK 9. |
/** | ||
* Patching for Java 9 classes, so that ASM can read them. | ||
*/ | ||
public final class Java9Support { |
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.
I see several JavaDoc warnings on this class. Even if the code is temporary I would prefer if our code comes without warnings.
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.
@marchof I suppose that those warnings are generated by Eclipse? I don't see warnings in IntelliJ , even when explicitly executing all built-in inspections for Javadocs. So could you please elaborate what needs to be fixed?
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.
Basically we require to have JavaDoc on all public Java classes and members.
- Javadoc: Missing comment for public declaration Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 25 Java Problem
- Javadoc: The method readClass(InputStream, boolean) from the type ClassReader is not visible Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 31 Java Problem
- Javadoc: Missing tag for return type Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 33 Java Problem
- Javadoc: Missing tag for parameter is Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 33 Java Problem
- Javadoc: Missing tag for parameter close Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 33 Java Problem
- Javadoc: Missing tag for declared exception IOException Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 34 Java Problem
- Javadoc: Missing comment for public declaration Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 79 Java Problem
- Javadoc: Missing comment for public declaration Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 83 Java Problem
- Javadoc: Missing comment for public declaration Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 87 Java Problem
- Javadoc: Missing comment for public declaration Java9Support.java /org.jacoco.core/src/org/jacoco/core/internal line 94 Java Problem
I wonder whether we should drop |
@Godin Beside my comments I'm ok with this PR! |
@marchof I simplified code and added Javadocs. About asymmetry: indeed it bothers. This is the only place where we expose ClassReader, but not the only place where we expose ASM APIs. Removal - is an API change. I don't think that it is critical for experimental support of Java 9 class file format. So IMO we should consider separately question about marking it as deprecated and further removal. WDYT? |
@Godin I agree to remove this API in a separate request. I just came across this as it won't work for Java 9. |
FYI (sorry if this is the wrong forum for this comment), we override analyzeClass(ClassReader) in order to filter which classes should be analyzed: for historical reasons, module boundaries in our product are not cleanly separated by archive, so we use package filters here. It would be ideal if there were still some way for us to do that efficiently before you remove that method (we can also skip the ICoverageVisitor.visitCoverage event, but that's less efficient since Analyzer's ASM processing still occurs). |
@bjkail No need to apologize. In fact thank you for this valuable information. As far as I understood you're doing something like
if so, wondering whether you can replace it by
? |
Well, more like this:
Regardless, we could instead override |
For the filtering API story we will need proper call-backs anyways. |
JDK 9 EA build 119 is available for testing, so let's go ahead with merging of those changes. And let's handle raised points separately from this PR, if it is needed or would be needed. And for the record without those changes execution of JaCoCo with JDK 9 EA b 119 fails with message like
which could be improved - something like "cannot read class". |
https://bugs.openjdk.java.net/browse/JDK-8150011