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

EXPERIMENTAL: Remove SecurityManager #1353

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -16,7 +16,6 @@
import org.mozilla.javascript.EvaluatorException;
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.RhinoException;
import org.mozilla.javascript.SecurityUtilities;
import org.mozilla.javascript.WrappedException;

/**
Expand Down Expand Up @@ -138,7 +137,7 @@ public void reportException(RhinoException ex) {
WrappedException we = (WrappedException) ex;
we.printStackTrace(err);
} else {
String lineSeparator = SecurityUtilities.getSystemProperty("line.separator");
String lineSeparator = System.getProperty("line.separator");
String msg = getExceptionMessage(ex) + lineSeparator + ex.getScriptStackTrace();
reportErrorMessage(
msg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.SecurityUtilities;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.debug.DebugFrame;
import org.mozilla.javascript.debug.DebuggableObject;
Expand Down Expand Up @@ -229,7 +228,7 @@ private String loadSource(String sourceUrl) {
// Can be a file name
try {
if (sourceUrl.startsWith("~/")) {
String home = SecurityUtilities.getSystemProperty("user.home");
String home = System.getProperty("user.home");
if (home != null) {
String pathFromHome = sourceUrl.substring(2);
File f = new File(new File(home), pathFromHome);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreePath;
import org.mozilla.javascript.Kit;
import org.mozilla.javascript.SecurityUtilities;
import org.mozilla.javascript.tools.debugger.treetable.JTreeTable;
import org.mozilla.javascript.tools.debugger.treetable.TreeTableModel;
import org.mozilla.javascript.tools.debugger.treetable.TreeTableModelAdapter;
Expand Down Expand Up @@ -639,7 +638,7 @@ private JMenu getWindowMenu() {
private String chooseFile(String title) {
dlg.setDialogTitle(title);
File CWD = null;
String dir = SecurityUtilities.getSystemProperty("user.dir");
String dir = System.getProperty("user.dir");
if (dir != null) {
CWD = new File(dir);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.mozilla.javascript.SecurityUtilities;

public class JSConsole extends JFrame implements ActionListener {
static final long serialVersionUID = 2551225560631876300L;
Expand All @@ -33,7 +32,7 @@ public class JSConsole extends JFrame implements ActionListener {

public String chooseFile() {
if (CWD == null) {
String dir = SecurityUtilities.getSystemProperty("user.dir");
String dir = System.getProperty("user.dir");
if (dir != null) {
CWD = new File(dir);
}
Expand Down

This file was deleted.

36 changes: 2 additions & 34 deletions rhino/src/main/java/org/mozilla/javascript/ClassCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
Expand All @@ -22,43 +21,12 @@ public class ClassCache implements Serializable {
private static final long serialVersionUID = -8866246036237312215L;
private static final Object AKEY = "ClassCache";
private volatile boolean cachingIsEnabled = true;
private transient Map<CacheKey, JavaMembers> classTable;
private transient Map<Class, JavaMembers> classTable;
private transient Map<JavaAdapter.JavaAdapterSignature, Class<?>> classAdapterCache;
private transient Map<Class<?>, Object> interfaceAdapterCache;
private int generatedClassSerial;
private Scriptable associatedScope;

/**
* CacheKey is a combination of class and securityContext. This is required when classes are
* loaded from different security contexts
*/
static class CacheKey {
final Class<?> cls;
final Object sec;

/** Constructor. */
public CacheKey(Class<?> cls, Object securityContext) {
this.cls = cls;
this.sec = securityContext;
}

@Override
public int hashCode() {
int result = cls.hashCode();
if (sec != null) {
result = sec.hashCode() * 31;
}
return result;
}

@Override
public boolean equals(Object obj) {
return (obj instanceof CacheKey)
&& Objects.equals(this.cls, ((CacheKey) obj).cls)
&& Objects.equals(this.sec, ((CacheKey) obj).sec);
}
}

/**
* Search for ClassCache object in the given scope. The method first calls {@link
* ScriptableObject#getTopLevelScope(Scriptable scope)} to get the top most scope and then tries
Expand Down Expand Up @@ -133,7 +101,7 @@ public synchronized void setCachingEnabled(boolean enabled) {
}

/** @return a map from classes to associated JavaMembers objects */
Map<CacheKey, JavaMembers> getClassCacheMap() {
Map<Class, JavaMembers> getClassCacheMap() {
if (classTable == null) {
// Use 1 as concurrency level here and for other concurrent hash maps
// as we don't expect high levels of sustained concurrent writes.
Expand Down
Loading
Loading