wala / WALA

T.J. Watson Libraries for Analysis, with frontends for Java, Android, and JavaScript, and may common static program analyses
http://github.com/wala/WALA
Eclipse Public License 2.0
758 stars 221 forks source link

Java 14 support #781

Open muscar opened 4 years ago

muscar commented 4 years ago

Hi,

The company I work with is using WALA for some internal projects. It looks like the library does not support Java 14. We get the following error: com.ibm.wala.ipa.cha.ClassHierarchyException: failed to load root<Primordial,Ljava/lang/Object> of class hierarchy.

Looking at the source code it seems like this could be "solved" by just changing the version range check in com.ibm.wala.shrike/src/main/java/com/ibm/wala/shrikeCT/ClassReader.java:

--- a/com.ibm.wala.shrike/src/main/java/com/ibm/wala/shrikeCT/ClassReader.java
+++ b/com.ibm.wala.shrike/src/main/java/com/ibm/wala/shrikeCT/ClassReader.java
@@ -67,7 +67,7 @@ public final class ClassReader implements ClassConstants {
     if (magic != MAGIC) {
       throw new InvalidClassFileException(offset, "bad magic number: " + magic);
     }
-    if (majorVersion < 45 || majorVersion > 57) {
+    if (majorVersion < 45 || majorVersion > 58) {
       throw new InvalidClassFileException(
           offset, "unknown class file version: " + majorVersion + '.' + minorVersion);
     }

I was wondering if there are any limitations that are preventing the library working with Java 14 projects, of if it's just a matter of changing the above check.

Thanks.

msridhar commented 4 years ago

@muscar that change will prevent WALA from fast-failing. I am guessing WALA will mostly work when given JDK 14 bytecodes, but there are definitely features we do not yet support. See this comment, which I'll reproduce some of here:

This is a good blog post outlining recent Java changes:

https://jakewharton.com/androids-java-9-10-11-and-12-support/

Two things jump out at me as possibly requiring additional WALA support:

  1. private interface methods (since JDK 9)
  2. Nestmates (since JDK 11)

I am not sure what will happen if the above language features are used (along with anything else added to the JVML since JDK 8).

Could you report back on your experience with running WALA on JDK 14 bytecodes with your patch applied? If it seems to work ok for you, maybe we'll change the main branch and include the bumped version number.