Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8258147: Modernize Nashorn code #5

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected NashornException(final String msg, final String fileName, final int li
* @param column column number
*/
protected NashornException(final String msg, final Throwable cause, final String fileName, final int line, final int column) {
super(msg, cause == null ? null : cause);
super(msg, cause);
this.fileName = fileName;
this.line = line;
this.column = column;
Expand All @@ -94,7 +94,7 @@ protected NashornException(final String msg, final Throwable cause, final String
* @param cause exception cause
*/
protected NashornException(final String msg, final Throwable cause) {
super(msg, cause == null ? null : cause);
super(msg, cause);
// Hard luck - no column number info
this.column = -1;
// We can retrieve the line number and file name from the stack trace if needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,14 @@ private static String getMessage(final String msgId, final String... args) {
// throw ParseException on first error from script
final ErrorManager errMgr = new Context.ThrowErrorManager();
// create new Nashorn Context
this.nashornContext = AccessController.doPrivileged(new PrivilegedAction<Context>() {
@Override
public Context run() {
try {
return new Context(options, errMgr, appLoader, classFilter);
} catch (final RuntimeException e) {
if (Context.DEBUG) {
e.printStackTrace();
}
throw e;
this.nashornContext = AccessController.doPrivileged((PrivilegedAction<Context>) () -> {
try {
return new Context(options, errMgr, appLoader, classFilter);
} catch (final RuntimeException e) {
if (Context.DEBUG) {
e.printStackTrace();
}
throw e;
}
}, CREATE_CONTEXT_ACC_CTXT);

Expand Down Expand Up @@ -342,17 +339,14 @@ private ScriptObjectMirror createGlobalMirror() {

// Create a new Nashorn Global object
private Global createNashornGlobal() {
final Global newGlobal = AccessController.doPrivileged(new PrivilegedAction<Global>() {
@Override
public Global run() {
try {
return nashornContext.newGlobal();
} catch (final RuntimeException e) {
if (Context.DEBUG) {
e.printStackTrace();
}
throw e;
final Global newGlobal = AccessController.doPrivileged((PrivilegedAction<Global>) () -> {
try {
return nashornContext.newGlobal();
} catch (final RuntimeException e) {
if (Context.DEBUG) {
e.printStackTrace();
}
throw e;
}
}, CREATE_GLOBAL_ACC_CTXT);

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

package org.openjdk.nashorn.api.scripting;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -272,7 +271,7 @@ private static void checkConfigPermission() {
}

private static List<String> immutableList(final String... elements) {
return Collections.unmodifiableList(Arrays.asList(elements));
return List.of(elements);
}

private static ClassLoader getAppClassLoader() {
Expand Down
Loading