Skip to content

Commit

Permalink
Migrating to Java 20
Browse files Browse the repository at this point in the history
  • Loading branch information
mxro committed Jul 5, 2023
1 parent d0adb9b commit 5aa8ffc
Show file tree
Hide file tree
Showing 39 changed files with 73 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-20">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 9, 10, 11, 12, 13 ]
java: [ 20 ]
name: Java ${{ matrix.java }} build
steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 4 additions & 4 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=20
org.eclipse.jdt.core.compiler.compliance=20
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=20
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
"java.configuration.updateBuildConfiguration": "automatic"
}
30 changes: 14 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>19.2.1</version>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>19.2.1</version> <!-- or any later version -->
<version>23.0.0</version> <!-- or any later version -->
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>19.2.1</version>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>19.2.1</version>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -70,6 +70,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.2</version>
</dependency>

</dependencies>

<!-- XXXXXXXXXXXXXX Maven declarations XXXXXXXXXXXXXXXXXX -->
Expand Down Expand Up @@ -114,9 +120,9 @@

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>20</release>
</configuration>
</plugin>

Expand Down Expand Up @@ -312,28 +318,20 @@

</build>

<distributionManagement>
<repository>
<id>bintray-javadelight-javadelight</id>
<name>javadelight-javadelight</name>
<url>https://api.bintray.com/maven/javadelight/javadelight/delight-graaljs-sandbox/;publish=1</url>
</repository>
</distributionManagement>


<developers>
<developer>
<id>mxro</id>
<name>Max Rohde</name>
<email>noemail@mxro.de</email>
<url>http://www.mxro.de/</url>
<url>https://www.mxro.de/</url>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+10</timezone>
<organization>pureleap</organization>
<organizationUrl>http://www.pureleap.com</organizationUrl>
<organizationUrl>https://www.pureleap.com</organizationUrl>
</developer>
</developers>

Expand Down
41 changes: 21 additions & 20 deletions src/main/java/delight/graaljssandbox/internal/GraalSandboxImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,7 @@ protected Bindings secureBindings(Bindings bindings) {
@Override
public Object eval(final String js, final SandboxScriptContext scriptContext, final Bindings bindings)
throws ScriptCPUAbuseException, ScriptException {
Set<String> addedKeys = new HashSet<>();
if (scriptContext != null) {
Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);

Bindings contextBindings = scriptContext.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
if (contextBindings != null) {
for (String key : contextBindings.keySet()) {
if (engineBindings.get(key) != null)
contextBindings.remove(key);
else
addedKeys.add(key);
}
}
}
final Set<String> addedKeys = new HashSet<>();
produceSecureBindings(); // We need this here for bindings
final JsSanitizer sanitizer = getSanitizer();
// see https://github.com/javadelight/delight-nashorn-sandbox/issues/73
Expand All @@ -165,16 +152,30 @@ public Object eval(final String js, final SandboxScriptContext scriptContext, fi
if (scriptContext == null) {
securedJs = blockAccessToEngine + sanitizer.secureJs(js);
} else {
// Unfortunately, blocking access to the engine property inteferes with setting
// a script context
// needs further investigation
// Unfortunately, blocking access to the engine property interferes with setting
// a script context needs further investigation
securedJs = sanitizer.secureJs(js);
}
final Bindings securedBindings = secureBindings(bindings);
if (bindings != null)
addedKeys.addAll(bindings.keySet());


EvaluateOperation op;
final Bindings securedBindings = secureBindings(bindings);
if (scriptContext != null) {
// Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);

// Bindings contextBindings = scriptContext.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
// if (contextBindings != null) {
// for (String key : contextBindings.keySet()) {
// if (engineBindings.get(key) != null)
// contextBindings.remove(key);
// else
// addedKeys.add(key);
// }
// }

// if (bindings != null) {
// addedKeys.addAll(bindings.keySet());
// }
op = new EvaluateOperation(isStrict ? "'use strict';" + securedJs : securedJs,
scriptContext.getContext(),
securedBindings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

@SuppressWarnings("all")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.junit.Before;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.BracesException;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;
import junit.framework.Assert;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestAllowAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestAllowAccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

@SuppressWarnings("all")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.junit.Ignore;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestBindingsInsert {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;
import junit.framework.Assert;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestBraces.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.BracesException;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestBuiltInObjectsAccess {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestClassForName.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.graalvm.polyglot.PolyglotException;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import junit.framework.Assert;

public class TestClassForName {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestCustomCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.SecuredJsCache;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;
import junit.framework.Assert;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestEval.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestEval {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestEvalWithScriptBindings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.SandboxScriptContext;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.SandboxScriptContext;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.SandboxScriptContext;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestExceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

@SuppressWarnings("all")
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestExit.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.junit.Ignore;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestExit {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestGetFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;
import junit.framework.Assert;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestGlobalVariable {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestIfElse.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestIfElse {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestInaccessible.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestInaccessible {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/delight/graaljssandbox/TestInvocable.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestInvocable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.Assert;
import org.junit.Test;

import delight.nashornsandbox.NashornSandbox;
import delight.nashornsandbox.exceptions.ScriptCPUAbuseException;

public class TestKeepVariables {
Expand Down
Loading

0 comments on commit 5aa8ffc

Please sign in to comment.