mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Remove reference to parent scope for Java methods. This was resulting in dangling
references that were never released to a large pool of objects.
This commit is contained in:
parent
6a76191c91
commit
fc2ff1cb84
@ -161,7 +161,6 @@ class JavaMembers {
|
||||
if (methodOrCtor instanceof Constructor) {
|
||||
NativeJavaConstructor fun =
|
||||
new NativeJavaConstructor((Constructor)methodOrCtor);
|
||||
fun.setParentScope(scope);
|
||||
fun.setPrototype(prototype);
|
||||
member = fun;
|
||||
ht.put(name, fun);
|
||||
@ -173,7 +172,6 @@ class JavaMembers {
|
||||
((NativeJavaMethod)member).getMethods().length > 1 ) {
|
||||
NativeJavaMethod fun =
|
||||
new NativeJavaMethod((Method)methodOrCtor, name);
|
||||
fun.setParentScope(scope);
|
||||
fun.setPrototype(prototype);
|
||||
ht.put(name, fun);
|
||||
member = fun;
|
||||
@ -273,7 +271,6 @@ class JavaMembers {
|
||||
FieldAndMethods fam = new FieldAndMethods(method.getMethods(),
|
||||
field,
|
||||
null);
|
||||
fam.setParentScope(scope);
|
||||
fam.setPrototype(ScriptableObject.getFunctionPrototype(scope));
|
||||
getFieldAndMethodsTable(isStatic).put(name, fam);
|
||||
ht.put(name, fam);
|
||||
@ -305,7 +302,6 @@ class JavaMembers {
|
||||
NativeJavaMethod fun = (NativeJavaMethod) ht.get(name);
|
||||
if (fun == null) {
|
||||
fun = new NativeJavaMethod();
|
||||
fun.setParentScope(scope);
|
||||
fun.setPrototype(ScriptableObject.getFunctionPrototype(scope));
|
||||
ht.put(name, fun);
|
||||
fun.add(method);
|
||||
@ -480,7 +476,6 @@ class JavaMembers {
|
||||
FieldAndMethods fam = (FieldAndMethods) e.nextElement();
|
||||
fam = (FieldAndMethods) fam.clone();
|
||||
fam.setJavaObject(javaObject);
|
||||
fam.setParentScope(scope);
|
||||
result.put(fam.getName(), fam);
|
||||
}
|
||||
return result;
|
||||
|
@ -220,18 +220,10 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
||||
" class = " + actualType);
|
||||
}
|
||||
|
||||
// XXX set prototype && parent
|
||||
if (wrapped == Undefined.instance)
|
||||
return wrapped;
|
||||
if (wrapped == null && staticType == Void.TYPE)
|
||||
return Undefined.instance;
|
||||
if (retval != wrapped && wrapped instanceof Scriptable) {
|
||||
Scriptable s = (Scriptable)wrapped;
|
||||
if (s.getPrototype() == null)
|
||||
s.setPrototype(parent.getPrototype());
|
||||
if (s.getParentScope() == null)
|
||||
s.setParentScope(parent.getParentScope());
|
||||
}
|
||||
return wrapped;
|
||||
} catch (IllegalAccessException accessEx) {
|
||||
throw Context.reportRuntimeError(accessEx.getMessage());
|
||||
|
@ -161,7 +161,6 @@ class JavaMembers {
|
||||
if (methodOrCtor instanceof Constructor) {
|
||||
NativeJavaConstructor fun =
|
||||
new NativeJavaConstructor((Constructor)methodOrCtor);
|
||||
fun.setParentScope(scope);
|
||||
fun.setPrototype(prototype);
|
||||
member = fun;
|
||||
ht.put(name, fun);
|
||||
@ -173,7 +172,6 @@ class JavaMembers {
|
||||
((NativeJavaMethod)member).getMethods().length > 1 ) {
|
||||
NativeJavaMethod fun =
|
||||
new NativeJavaMethod((Method)methodOrCtor, name);
|
||||
fun.setParentScope(scope);
|
||||
fun.setPrototype(prototype);
|
||||
ht.put(name, fun);
|
||||
member = fun;
|
||||
@ -273,7 +271,6 @@ class JavaMembers {
|
||||
FieldAndMethods fam = new FieldAndMethods(method.getMethods(),
|
||||
field,
|
||||
null);
|
||||
fam.setParentScope(scope);
|
||||
fam.setPrototype(ScriptableObject.getFunctionPrototype(scope));
|
||||
getFieldAndMethodsTable(isStatic).put(name, fam);
|
||||
ht.put(name, fam);
|
||||
@ -305,7 +302,6 @@ class JavaMembers {
|
||||
NativeJavaMethod fun = (NativeJavaMethod) ht.get(name);
|
||||
if (fun == null) {
|
||||
fun = new NativeJavaMethod();
|
||||
fun.setParentScope(scope);
|
||||
fun.setPrototype(ScriptableObject.getFunctionPrototype(scope));
|
||||
ht.put(name, fun);
|
||||
fun.add(method);
|
||||
@ -480,7 +476,6 @@ class JavaMembers {
|
||||
FieldAndMethods fam = (FieldAndMethods) e.nextElement();
|
||||
fam = (FieldAndMethods) fam.clone();
|
||||
fam.setJavaObject(javaObject);
|
||||
fam.setParentScope(scope);
|
||||
result.put(fam.getName(), fam);
|
||||
}
|
||||
return result;
|
||||
|
@ -220,18 +220,10 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
||||
" class = " + actualType);
|
||||
}
|
||||
|
||||
// XXX set prototype && parent
|
||||
if (wrapped == Undefined.instance)
|
||||
return wrapped;
|
||||
if (wrapped == null && staticType == Void.TYPE)
|
||||
return Undefined.instance;
|
||||
if (retval != wrapped && wrapped instanceof Scriptable) {
|
||||
Scriptable s = (Scriptable)wrapped;
|
||||
if (s.getPrototype() == null)
|
||||
s.setPrototype(parent.getPrototype());
|
||||
if (s.getParentScope() == null)
|
||||
s.setParentScope(parent.getParentScope());
|
||||
}
|
||||
return wrapped;
|
||||
} catch (IllegalAccessException accessEx) {
|
||||
throw Context.reportRuntimeError(accessEx.getMessage());
|
||||
|
Loading…
Reference in New Issue
Block a user