apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.68k stars 853 forks source link

Test compile jsp not working with target/source 11 #6606

Open aboi-83 opened 1 year ago

aboi-83 commented 1 year ago

Apache NetBeans version

Apache NetBeans 19

What happened

After migrating my project on java 11, I can't build the project with the option "Test compile all JSP files during build".

Whit this flag off the build ends without errors. But with flag on, I get the error:

Exception in thread "main" java.lang.IllegalArgumentException: PWC6309: Illegal compilerSourceVM: 11
    at org.apache.jasper.JspC.setCompilerSourceVM(JspC.java:684)
    at org.netbeans.modules.web.project.ant.JspC.main(JspC.java:55)
C:\Users\andre\Work\Projects\EramCore2\Eram\nbproject\build-impl.xml:927: Java returned: 1
BUILD FAILED (total time: 15 seconds)

My java distribution is Corretto-11.0.12.7.1

How to reproduce

  1. Create a new project: Java with Ant -> JavaWeb -> WebApplication
  2. Select Tomcat as target server (in my case Tomcat 9.0.82)
  3. Select Java EE 8 Web as Java EE Version
  4. Complete the wizard
  5. Right click on project and select properties: enable "Test compile all JSP files during build" in Build -> Compiling
  6. Create a new jsp
  7. Build the project

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

JDK 11

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

roberto-cisternino commented 9 months ago

The same error occurs using Java 17. I compiled all JARS, and WAR without problem, but when I compile from the EAR I experience the same error as printed below:

Exception in thread "main" java.lang.IllegalArgumentException: PWC6309: Illegal compilerSourceVM: 17 at org.apache.jasper.JspC.setCompilerSourceVM(JspC.java:684) at org.netbeans.modules.web.project.ant.JspC.main(JspC.java:55) \nbproject\build-impl.xml:212: The following error occurred while executing this line: \nbproject\build-impl.xml:997: Java returned: 1 BUILD FAILED (total time: 43 seconds)

aboi-83 commented 8 months ago

I think the problem is related to the library netbeans\enterprise\modules\ext\glassfish-jspparser-5.1.0.jar.

I decompiled the jar and the max supported version is 1.8:

public void setCompilerTargetVM(String vm) {
   String tvm = vm;
      if ("5".equals(vm)) {
         vm = "1.5";
      } else if ("6".equals(vm)) {
         vm = "1.6";
      } else if ("7".equals(vm)) {
         vm = "1.7";
      } else if ("8".equals(vm)) {
         vm = "1.8";
      }
      if (!"1.1".equals(vm) && !"1.2".equals(vm) && !"1.3".equals(vm) && !"1.4".equals(vm) && !"1.5".equals(vm) && !"1.6".equals(vm) && !"1.7".equals(vm) && !"1.8".equals(vm)) {
         throw new IllegalArgumentException(Localizer.getMessage("jspc.illegalCompilerTargetVM", tvm));
      } else {
         Double targetVersion = Double.valueOf(vm);
         if (targetVersion.compareTo(Double.valueOf(myJavaVersion)) > 0) {
            throw new IllegalArgumentException(Localizer.getMessage("jspc.compilerTargetVMTooHigh", vm));
         } else {
            this.compilerTargetVM = vm;
         }
      }
   }

The problem is still present in Netbeans 21.