Play 1.4.4 doesn't work with Java 8?

50 views
Skip to first unread message

Manuel Paccagnella

unread,
Sep 18, 2017, 9:13:21 AM9/18/17
to playone

Hi,

Since JDK 1.7 is in EOL for a long time now and it’s not available anymore to download in the Oracle website, I’ve tried to move a work project to Play 1.4.4 and JDK 1.8. Unfortunately, it doesn’t work.

After configuring the source level in conf/application.conf:

java.source=1.8

I get this exception multiple times at startup:

play.exceptions.CompilationException: Syntax error, parameterized types are only available if source level is 1.5
        at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:264)
        at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:672)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:516)
        at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:300)
        at play.classloading.ApplicationClasses$ApplicationClass.compile(ApplicationClasses.java:288)
        at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:164)
        at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:83)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:212)
        at play.Play.init(Play.java:305)
        at play.server.Server.main(Server.java:160)

In the context of plugins loading. Both Play and custom ones:

Error loading plugin LoadingPluginInfo{name='DocViewerPlugin', index=1000, url=file:/path/to/play-1.4.4/modules/docviewer/app/play.plugins}

Adding some log statements to ApplicationCompiler and using the customized Play build to compile my application, I’ve seen that for some reason even if the settings assembled by Play are correct (source, target and compliance level is “1.8”), when the JDT Compiler instance has been constructed, its CompilerOpitions corresponding parameters have the default value 0 (in other words, seems like the “1.8” version string is not recognized). It’s quite strange since both in the org.eclipse.jdt.internal.compiler.impl.CompilerOptions (decompiled) sources both #versionFromJdkLevel() and #versionToJdkLevel() support this value.

I’ve also tried to force the correct values after the fact:

jdtCompiler.options.sourceLevel = 3407872L;
jdtCompiler.options.targetJDK = 3407872L;
jdtCompiler.options.complianceLevel = 3407872L;

For reference, here is the relevant CompilerOptions conversion method that should be used internally:

public static long versionToJdkLevel(Object versionID) {
  if (versionID instanceof String) {
    String version = (String)versionID;
    if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
      switch(version.charAt(2)) {
        case '1':
          return 2949123L;
        case '2':
          return 3014656L;
        case '3':
          return 3080192L;
        case '4':
          return 3145728L;
        case '5':
          return 3211264L;
        case '6':
          return 3276800L;
        case '7':
          return 3342336L;
        case '8':
          return 3407872L;
        default:
          return 0L;
      }
    }

    if ("jsr14".equals(versionID)) {
      return 3145728L;
    }

    if ("cldc1.1".equals(versionID)) {
      return 2949124L;
    }
  }

  return 0L;
}

But unfortunately, I get a different error (always for the plugins):

play.exceptions.UnexpectedException: Unexpected Error
        at play.classloading.ApplicationCompiler$1.findType(ApplicationCompiler.java:212)
        at play.classloading.ApplicationCompiler$1.findType(ApplicationCompiler.java:158)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102)
        at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
        at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:168)
        at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:465)
        at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleImport(CompilationUnitScope.java:519)
        at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInImports(CompilationUnitScope.java:368)
        at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:444)
        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:752)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464)
        at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:316)
        at play.classloading.ApplicationClasses$ApplicationClass.compile(ApplicationClasses.java:288)
        at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:164)
        at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:83)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:212)
        at play.Play.init(Play.java:305)
        at play.server.Server.main(Server.java:160)
Caused by: org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
        at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:372)
        at play.classloading.ApplicationCompiler$1.findType(ApplicationCompiler.java:178)
        ... 19 more

Do you have any idea on what’s the problem here?

Thank you very much

Reply all
Reply to author
Forward
0 new messages