-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Upgrade to ASM 6 #600
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
Upgrade to ASM 6 #600
Conversation
new ClassReader(Java9Support.downgradeIfRequired(buffer))); | ||
} catch (final RuntimeException cause) { | ||
analyzeClass(new ClassReader(buffer)); | ||
} catch (final Exception cause) { |
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.
Note that here I changed from RuntimeException to Exception
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.
Wondering why? how this is related to ASM 6? I'm asking because we had some improvements and quite some nasty regressions/missed cases of exception handling exactly here.
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.
Initially, I got some tests with errors (the test was expecting an exception with a actual message, but null was given).
Later I noticed that the method Instrumenter.instrument(InputStream...)
need to be wrapped with a try-catch block (noticed by looking the previous state in the git history).
But I didn't know if it was related
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.
@Godin I double checked my changes. Looks that this can be reverted.
} catch (final IOException e) { | ||
throw analyzerError(location, e); | ||
analyzeClass(new ClassReader(input)); | ||
} catch (final Exception cause) { |
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.
And here from IOException to Exception
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.
Also wondering why? and how this is related to ASM 6?
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.
Same comment here, I got a test with an exception (I think was an ArrayIndexOutOfBoundsException
in this case)
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.
But reverting this change I got Failed tests: testAnalyzeClass_BrokenStream(org.jacoco.core.analysis.AnalyzerTest): expected:<Error while analyzing BrokenStream.> but was:<null>
@andrioli thank you for your contribution 👍 and congratulations with round number 600 😉
This is definitely good thing since should bring fixes for bugs reported by us. @marchof I believe that we would need to add tests for them to prevent regressions since they are not tested in ASM explicitly. Also maybe will be better to do this update after finishing work on "filtering" - to ease its integration into Eclipse EclEmma, recall that it consumes ASM from Eclipse Orbit.
This is unavoidable warning, meaning that initially non-exported packages became visible at least for classes in final JAR - see mention of this in announcement of release of |
new ClassReader(Java9Support.downgradeIfRequired(buffer))); | ||
} catch (final RuntimeException cause) { | ||
analyzeClass(new ClassReader(buffer)); | ||
} catch (final Exception cause) { |
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.
Wondering why? how this is related to ASM 6? I'm asking because we had some improvements and quite some nasty regressions/missed cases of exception handling exactly here.
} catch (final IOException e) { | ||
throw analyzerError(location, e); | ||
analyzeClass(new ClassReader(input)); | ||
} catch (final Exception cause) { |
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.
Also wondering why? and how this is related to ASM 6?
try { | ||
bytes = Java9Support.readFully(input); | ||
return instrument(new ClassReader(input)); |
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.
If instrumentation fails, then exception won't have location information due to this usage of instrument(ClassReader)
instead of previously used instrument(byte[], String)
. Maybe simply preserve readFully
?
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.
This reminds me again recurring old wish to deprecate instrument(ClassReader)
or at least add a note.
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.
@Godin IMHO we can even just remove it. But it's a separate issue though.
try { | ||
output.write(instrument(input, name)); | ||
} catch (final RuntimeException e) { | ||
throw instrumentError(name, e); |
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.
IMO addition of this is an indication of regression in instrument(InputStream, String)
.
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.
And if we don't wrap it with a try-catch block we got Tests in error: testInstrumentAll_BrokenClassFileInZip(org.jacoco.core.instr.InstrumenterTest): 67
that is the ArrayOutOfBoundsException
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.
@andrioli if you fix the regression in instrument(InputStream, String)
described in #600 (comment) , then test won't be failing and try-catch won't be needed here.
@Godin As Eclipse platform is working towards Java 9 I hope ASM 6 will show up in orbit soon (AFAIK ASM is required for PDE). You're right about regression tests. Looks like the primary purpose of JaCoCo is to serve as a regression test suite for ASM and the JDK. 😉 But this is not something we can request from @andrioli . |
@marchof Don't know specifically about PDE, but AFAIK for Oxygen.1a, whose focus is Java 9, there were no interest in ASM 6 BETA (see https://dev.eclipse.org/mhonarc/lists/orbit-dev/msg04882.html) and AFAIK final version was released too late for inclusion into Oxygen.1a. But that's doesn't matter: by saying "ease integration", I meant exactly "easier", otherwise will just need to work on its addition as did for the two previous versions. There are quite some mess in sources of ASM published to Maven Central as usual, but maybe I'll find time to deal with this and raise CQ for addition.
😆
This wasn't a request, just a remark/reminder for us. |
Done. @Godin Now is even easier to understand the changes. Unfortunately Travis is failing. Looks that the JDK download URL is not valid. Maybe you can fix the environment variables and re-run the jobs to keep everything green 😄 |
/** | ||
* File handling utilities | ||
*/ | ||
public final class Files { |
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.
This is not just about files, because method inside this class works for any InputStream
, so better to change name. I'll do this during rebase.
@@ -59,8 +58,8 @@ public void teardown() { | |||
@Test | |||
public void should_not_loose_InnerClasses_attribute() throws Exception { |
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.
After upgrade this test fails on JDK 5 due to another ASM bug - https://gitlab.ow2.org/asm/asm/issues/317800 😆
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.
However ASM 5.2 already had an issues in a similar scenario - see #487
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.
Given that scenarios are limited to class files without frames and with big methods that require wide jumps, and that there was problem #487 in the exact same scenarios, I do not consider this as regression.
In these scenarios after update of ASM, we'll be producing class files with frames that are not supposed to be present. While this can cause problems of reading of produced classes by the ASM as described in https://gitlab.ow2.org/asm/asm/issues/317800 , seems that JVM can read such classes and I believe that doesn't perform validation of frames, so this should not cause execution problems.
And taking into account that this update will resolve #487, #544, #584 and #606, I propose to update test to make it pass, and merge update into master.
Also seems that we can implement removal of these unwanted frames after instrumentation if there were no frames in original class - see my comment in ASM issue (https://gitlab.ow2.org/asm/asm/issues/317800#note_9609). However I propose to defer this and merge update without this - can implement later and maybe soon there will be ASM 6.0.1 with fix (https://gitlab.ow2.org/asm/asm/merge_requests/46).
@marchof WDYT?
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.
@Godin Let's move forward to 6.0 without the workaround -- a you propose. I assume that 6.0.1 will be there before we get the first bug report for old class files.
fcad229
to
c68f464
Compare
Upgrade to new ASM release 6.0. This version supports Java 9 class files, so I also removed Java9Support class.
This ASM version comes with a module-info.class file (major 53) but the shade plugin don't like it. So I also updated the maven-shade-plugin.
The shade plugin will output some warnings:
I tried to apply a filter but the filter have no effect removing the warn message. Looking in the bundled JAR the module-info.class looks to not be included. So I think is ok to ignored the warn.
I built with success in my machine with Maven 3.5.0 and JDK 1.7.0_80, 1.8.0_144 and 9+181. Also tried with Maven 3.2.5 and JDK 1.6.0_65