Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278040

Preview features cannot be enabled for compiler plugins

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When compiling a source file that uses preview features, it is mandatory to specify the --enable-preview flag. This flag doesn't seem to work for compiler plugins specified using the flag -Xplugin:plugin_name. The following exception is thrown:
      Exception in thread "main" java.lang.UnsupportedClassVersionError: Preview features are not enabled for it/auties/optional/util/FunctionalExpressionDesugarer$FunctionalExpressionType (class file version 61.65535). Try running with '--enable-preview'
              at java.base/java.lang.ClassLoader.defineClass1(Native Method)
              at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
              at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
              at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:519)
              at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
              at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
              at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
              at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
              at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
              at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
              at it.auties.optional.plugin.OptionalPlugin.init(OptionalPlugin.java:42)
              at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:255)
              at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:229)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:292)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

      Here is the javac command that I used to build my test:
      javac --enable-preview -cp classpath --release 17 -Xplugin:FastOptional OptionBenchmark.java




            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: