Support Article
Java code fails to compile with Pega 7.2
SA-21570
Summary
User runs Pega 7.2 with Java version 1.8.0_73.
However when using Java 1.8 functionality in a Java step, they get an error message stating that this is not supported for source levels below 1.7, implying that they are using Java 6 or even Java 5.
Error Messages
In this particular case, the error message was: "Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted."
If other Java 8 (Java 7) features are used, other error messages are likely.
Steps to Reproduce
Use any Java 1.8 functionality when writing a Java step.
Root Cause
Even Pega 7.2 is certified for the use with a Java 8 JVM, the source level for Java code to write to a Java step in PRPC is not Java 8, although it is not really clear whether it is set to 1.6 or still 1.5 in Pega 7.2.
This is because Pega is not using the platform compiler, that one that comes with the JVM itself, but the Java compiler from the Eclipse project.
If user is bit familiar with Eclipse as a development environment, one can remember that the compiler settings to select the code level, is independent from the target version.
So it is fixed the source level to 1.5 (1.6 respectively), while the target level is usually set to the platform level.
Resolution
As a conclusion, the behavior as reported by the customer is expected.
While compiled code (provided as a JAR or CLASS file) may make use of Java 8 functionality, the source of a Java step is still bound to Java 5 (or Java 6).
Published April 4, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.