apache / hop

Hop Orchestration Platform
https://hop.apache.org/
Apache License 2.0
1.14k stars 371 forks source link

[Bug]: User defined java class not using the correct java version. #5172

Open enjoyy2 opened 4 weeks ago

enjoyy2 commented 4 weeks ago

Apache Hop version?

2.8.0

Java version?

17.0.1

Operating system

Windows

What happened?

user defined java class. added the aws sdk v2 s3 dependencies jars into the C:\Work\apache-hop-client-2.8.0\hop\plugins\transforms\janino\lib . Created a custom java class, to import this packages and did some custom java code for s3 buckets.

when writing

// Build the S3 client with dynamic credentials S3Client s3 = S3Client.builder() .region(Region.US_EAST_1) // Change to your region .credentialsProvider(StaticCredentialsProvider.create(sessionCredentials)) .build();

janino compiler throws:

CompileException: Line 55, Column 40: Invocation of static interface methods only available for target version 8+ Root cause: CompileException: Line 55, Column 40: Invocation of static interface methods only available for target version 8+

i tried both with janino-3.1.11 and janino-3.1.12 .jar files

when printing out the java version from the same user defined java class (System.getProperty("java.version")), i get 17.0.1. so the java used is the correct one, but somehow the compiler does not see the correct java version.

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: C:\Users\dmusat\Downloads\maven-mvnd-1.0.2-windows-amd64\mvn Java version: 17.0.1, vendor: Oracle Corporation, runtime: C:\Work\openjdk-17.0.1_windows-x64_bin\jdk-17.0.1 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

tested out with both 2.8.0 and 2.12.0

dependencies for aws sdk are built with maven with correct java compiler version.

org.apache.maven.plugins maven-compiler-plugin 3.11.0 17 17 17

manifest: Manifest-Version: 1.0 Created-By: Maven JAR Plugin 3.4.1 Build-Jdk-Spec: 17

if i run the same code in an eclipse ide, it works as expected.

Image

Issue Priority

Priority: 3

Issue Component

Component: Transforms

hansva commented 4 weeks ago

We do not specify a target version on Janino, I guess that it is compiling using Java 8 as default.

ClassBodyEvaluator has a setTargetVersion