diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..873a882 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,6 @@ +{ + "name": "Java 17 Dev Container", + "image": "mcr.microsoft.com/devcontainers/java:17", + "settings": {}, + "extensions": [] +} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e935a91..ab20f69 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -37,6 +37,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 5de62b4..37e2eb5 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -14,10 +14,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'temurin' + java-version: '17' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c8aeb3a..ae9ed8c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,9 +16,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'temurin' + java-version: '17' - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 12fc0d0..bc81d14 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -6,30 +6,9 @@ 4.0.0 - - maven-install-plugin - - - hack-binary - clean - - install-file - - - ${JAVA_HOME}/lib/tools.jar - default - com.sun - tools - jdk1.8.0 - jar - true - - - - - - maven-shade-plugin - 3.0.0 + + maven-shade-plugin + 3.0.0 package @@ -44,20 +23,7 @@ - - - windows-profile - - ${JAVA_HOME}/lib/tools.jar - - - - mac-profile - - ${java.home}/../lib/tools.jar - - - + junit @@ -73,8 +39,8 @@ - 1.8 - 1.8 - - + 17 + 17 + + diff --git a/nb-configuration.xml b/nb-configuration.xml index 15dea5e..469d086 100644 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -13,6 +13,6 @@ You can copy and paste the single properties, into the pom.xml file and the IDE That way multiple projects can share the same settings (useful for formatting rules for example). Any value defined here will override the pom.xml file value but is only applicable to the current project. --> - JDK_1.8 - - + JDK_17 + + diff --git a/pom.xml b/pom.xml index aab310b..39c038d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,56 +4,41 @@ hellofunction 6.0.1 - 1.8 - 1.8 + 17 + 17 + 17 UTF-8 - - - - windows-profile - - true - - ${JAVA_HOME}/lib/tools.jar - - - - ${JAVA_HOME}/lib/tools.jar - - - - mac-profile - - false - - ${java.home}/../lib/tools.jar - - - - ${java.home}/../lib/tools.jar - - - + + + cagatay-gurturk + http://maven.cagataygurturk.com/releases + + + - - com.amazonaws - aws-java-sdk-bom - 1.12.789 - pom - import - + + com.amazonaws + aws-java-sdk-bom + 1.12.789 + pom + import + - - com.amazonaws - aws-java-sdk-lambda - 1.12.789 - + + com.amazonaws + aws-java-sdk-lambda + 1.12.789 + com.amazonaws @@ -85,10 +70,9 @@ org.eclipse.jdt - ecj - 3.42.0 - - + ecj + 3.42.0 + junit @@ -119,34 +103,34 @@ - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - com.cagataygurturk.lambda.LocalRunner - - handleRequest - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - true - - - - - - org.apache.maven.plugins - maven-shade-plugin - 2.3 - + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + com.cagataygurturk.lambda.LocalRunner + + handleRequest + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + true + + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + false diff --git a/src/main/java/run/myCode/compiler/JavaCodeCompiler.java b/src/main/java/run/myCode/compiler/JavaCodeCompiler.java index 5e14b44..22a3f47 100644 --- a/src/main/java/run/myCode/compiler/JavaCodeCompiler.java +++ b/src/main/java/run/myCode/compiler/JavaCodeCompiler.java @@ -17,11 +17,11 @@ import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; +import javax.tools.ToolProvider; -public class JavaCodeCompiler { - - private static final boolean DEBUG = Boolean.getBoolean("run.mycode.debug"); +public class JavaCodeCompiler { + + private static final boolean DEBUG = Boolean.getBoolean("run.mycode.debug"); /** * Compile Java source files into memory @@ -56,34 +56,34 @@ public static FromMemoryClassLoader compile(Iterable f final FromMemoryClassLoader classLoader = new FromMemoryClassLoader(urlcl); // get system compiler: - // Use the standard Java compiler provided by the JDK. This avoids ECJ - // attempting to resolve in-memory sources on disk which resulted in - // "File ... is missing" errors during tests. - final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + // Use the standard Java compiler provided by the JDK. This avoids ECJ + // attempting to resolve in-memory sources on disk which resulted in + // "File ... is missing" errors during tests. + final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); // create a diagnostic listener for compilation diagnostic message processing on // compilation WARNING/ERROR final CompileDiagnosticListener diag = new CompileDiagnosticListener(); final StandardJavaFileManager stdfileManager = compiler.getStandardFileManager(diag, Locale.ENGLISH, null); - InMemoryJavaFileManager fileManager = new InMemoryJavaFileManager(stdfileManager, classLoader); - for (JavaFileObject file : files) { - fileManager.addSource(file); - if (DEBUG) { - System.out.println("Compiling source " + file.getName()); - } - } + InMemoryJavaFileManager fileManager = new InMemoryJavaFileManager(stdfileManager, classLoader); + for (JavaFileObject file : files) { + fileManager.addSource(file); + if (DEBUG) { + System.out.println("Compiling source " + file.getName()); + } + } // specify options for compiler if (options == null) { options = new ArrayList<>(); } - // Build the classpath from the current folder and the system classpath - StringBuilder classpathBuilder = - new StringBuilder("." + - System.getProperty("path.separator") + - System.getProperty("java.class.path")); + // Build the classpath from the current folder and the system classpath + StringBuilder classpathBuilder = + new StringBuilder("." + + System.getProperty("path.separator") + + System.getProperty("java.class.path")); // Add any included jar files from the lib folder to the classpath (wildcard isn't working) try { @@ -108,16 +108,16 @@ public static FromMemoryClassLoader compile(Iterable f // Set the classpath and java version for the compiler options.addAll(Arrays.asList("-classpath", classpath)); - options.addAll(Arrays.asList("--release", "8")); + options.addAll(Arrays.asList("-17")); Writer out = new PrintWriter(System.out); // Compile the code - JavaCompiler.CompilationTask task = compiler.getTask(out, fileManager, diag, options, null, files); - if (DEBUG) { - System.out.println("Starting compilation with mem URIs"); - } - boolean result = task.call(); + JavaCompiler.CompilationTask task = compiler.getTask(out, fileManager, diag, options, null, files); + if (DEBUG) { + System.out.println("Starting compilation with mem URIs"); + } + boolean result = task.call(); // Return the classloader containing the compiled classes return classLoader; diff --git a/src/main/java/zss/compiler/MemoryCompiler.java b/src/main/java/zss/compiler/MemoryCompiler.java index 5014082..31a4f30 100644 --- a/src/main/java/zss/compiler/MemoryCompiler.java +++ b/src/main/java/zss/compiler/MemoryCompiler.java @@ -12,14 +12,14 @@ import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; +import javax.tools.ToolProvider; -/** - * Compiles in-memory source files into byte code using the standard JDK - * compiler. This avoids relying on the Eclipse compiler which attempted to - * resolve sources on disk. - */ -public class MemoryCompiler { +/** + * Compiles in-memory source files into byte code using the standard JDK + * compiler. This avoids relying on the Eclipse compiler which attempted to + * resolve sources on disk. + */ +public class MemoryCompiler { /** * Compile Java source files into memory * @@ -37,10 +37,10 @@ public static FromMemoryClassLoader compile(Iterable f // classloader final FromMemoryClassLoader classLoader = new FromMemoryClassLoader(urlcl); - // Use the standard JDK compiler to avoid ECJ attempting to read - // temporary files from disk which caused "File ... is missing" - // errors when compiling in memory. - final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + // Use the standard JDK compiler to avoid ECJ attempting to read + // temporary files from disk which caused "File ... is missing" + // errors when compiling in memory. + final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); // create a diagnostic listener for compilation diagnostic message processing on // compilation WARNING/ERROR @@ -51,10 +51,11 @@ public static FromMemoryClassLoader compile(Iterable f // specify options for compiler List options = new ArrayList<>(); - options.addAll( - Arrays.asList("-classpath", MemoryCompiler.class.getProtectionDomain().getCodeSource().getLocation() - + ":" + System.getProperty("java.class.path"))); - options.addAll(Arrays.asList("--release", "8", "-nowarn")); + options.addAll( + Arrays.asList("-classpath", MemoryCompiler.class.getProtectionDomain().getCodeSource().getLocation() + + ":" + System.getProperty("java.class.path"))); + options.addAll(Arrays.asList("-17", "-nowarn")); + Writer out = new PrintWriter(System.out); JavaCompiler.CompilationTask task = compiler.getTask(out, fileManager, diag, options, null, files);