ReZero's Utopia.

Jdk8 feature or trouble ?

Word count: 324Reading time: 2 min
2019/03/18 Share

Since jdk 8 update, some tools has broken cause it’s new feature. For example, javasisit:

Ebean lazyloading get failure that data not load all but only one attribute like UUID from children model.

And for the reason, finally found this: https://github.com/jboss-javassist/javassist/pull/10

The problem was in the getMethodref…() methods in ConstPool were the item returned was cast to MethodrefInfo(causing a ClassCastException when the item is in fact an InterfaceMethodrefInfo).
Looking at the code in ConstPool showed that both MethodrefInfo and InterfaceMethodrefInfo inherits from MemberrefInfo which actually has all the needed methods.
After changing the methods to use MemberrefInfo instead the getInterfaceMethodref…() methods were redundant.

Removing the getInterfaceMethodref…() methods required updating all the places that they were called to use getMethodref…() instead.
This in turn made it possible to refactor some classes (MethodCall, Executor, InstructionPrinter and CodeAnalyzer) to handle INVOKEINTERFACE in the same way as the other invoke opcodes.

Since the problem was caused by Java 8 code I wanted to add test code using Java 8 features.
I noticed that the fix for JASSIST-224 had already added Java 8-specific code (it uses java.lang.reflect.Parameter, which is new in Java 8)
so compiling the test cases already requires Java 8. I therefore first made a commit were I updated the maven-compiler-plugin configuration to set and > to “1.8”.


byte code

1
10: invokestatic  #4                  // InterfaceMethod java/util/stream/IntStream.range:(II)Ljava/util/stream/IntStream;

It is using invokestatic on an InterfaceMethodref (which is allowed in Java 8 since interfaces can now have static methods).

As the commiter said, it should be a backward compatibility, so he wanna use the new feature.
But the author of javasist seems not agree with the new feature for performance reason.
And for the large user base, the commiter finally takes the author point to reintroduce the old interface surrounded with the new method implemented.

CATALOG