mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-07 07:04:09 +00:00
Fixed bug. We weren't loading classes in bottom-up dependency order.
Subject: Re: another getClassLoader exception Date: Mon, 18 Oct 1999 22:01:24 -0400 From: Andrew Wason <aw@softcom.com> To: norris@netscape.com (Norris Boyd) CC: Howard Lin <howard@softcom.com> References: 1 , 2 At 05:03 PM 10/18/99 -0700, Norris Boyd wrote: >Are you still seeing this problem? Yes. I just did a CVS update to get the latest stuff and we still have this problem. I wrote a standalone sample program that duplicates the problem. Run JSSupport and you should get this exception: defineClass org.mozilla.javascript.gen.c2 Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/javascript/gen/c1 at java.lang.ClassLoader.resolveClass0(Native Method) at java.lang.ClassLoader.resolveClass(ClassLoader.java:545) at JSSupport$MySecuritySupport$DataClassLoader.loadClass(JSSupport.java:89) at JSSupport$MySecuritySupport.defineClass(JSSupport.java:47) at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java, Compiled Code) at org.mozilla.javascript.Context.compile(Context.java:1761) at org.mozilla.javascript.Context.compile(Context.java:1691) at org.mozilla.javascript.Context.compileReader(Context.java:810) at org.mozilla.javascript.Context.evaluateReader(Context.java:725) at org.mozilla.javascript.Context.evaluateString(Context.java:692) at JSSupport.<init>(JSSupport.java:20) at JSSupport.main(JSSupport.java:9) Andrew >--N > >Andrew Wason wrote: > > > At 04:54 PM 10/12/99 -0700, Norris Boyd wrote: > > >I just checked in changes so that the class calling ScriptRuntime (c5 > in your > > >case) will load the class itself using the normal Java classloading > mechanism > > >rather than an explicit call to the class loader. I pushed the bits up > to the > > >ftp site, but it takes a bit to propagate. > > > > I get this exception now (debugging statements are from my code): > > > > SecuritySupport.defineClass org.mozilla.javascript.gen.c5 > > DataClassLoader.loadClass org.mozilla.javascript.gen.c5 > > DataClassLoader.loadClass org.mozilla.javascript.gen.c4 > > using default loader com.softcom.realjava.PluginClassLoader@da9486a0 > > java.lang.NoClassDefFoundError: org/mozilla/javascript/gen/c4 > > at java.lang.ClassLoader.resolveClass0(Native Method) > > at java.lang.ClassLoader.resolveClass(ClassLoader.java:545) > > at > > > com.softcom.realjava.plugins.RealJavaScript$RealJavaScriptSecuritySupport$Da > > taClassLoader.loadClass(RealJavaScript.java:410) > > at > > > com.softcom.realjava.plugins.RealJavaScript$RealJavaScriptSecuritySupport.de > > fineClass(RealJavaScript.java:352) > > at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java, > > Compiled Code) > > at org.mozilla.javascript.Context.compile(Context.java:1761) > > at org.mozilla.javascript.Context.compile(Context.java:1691) > > at org.mozilla.javascript.Context.compileReader(Context.java:810) > > > > So when c5 is being loaded by my SecuritySupport, it also needs to load c4. > > I decompiled org.mozilla.javascript.gen.c5 and it's constant pool > > references CLASS org.mozilla.javascript.gen.c4, so c5 is dependent on c4 > > being loadable. Is the problem that c5 is being loaded before the > > optimizer has defined c4? > > > > I get the above exception for some classes and not others. It seems > > consistent that I always get it for classes with dependencies on other > > optimizer classes that haven't been generated yet. > > > > Andrew > > > > -- > > Andrew Wason > > SoftCom, Inc. > > aw@softcom.com -- Andrew Wason SoftCom, Inc. aw@softcom.com JSSupport.java Name: JSSupport.java Type: Java Source File (text/java) Encoding: base64
This commit is contained in:
parent
87c84fdd19
commit
aec69cc2f4
@ -72,7 +72,8 @@ public class Codegen extends Interpreter {
|
||||
ClassNameHelper nameHelper)
|
||||
throws IOException
|
||||
{
|
||||
Hashtable classFiles = new Hashtable(23);
|
||||
Vector classFiles = new Vector();
|
||||
Vector names = new Vector();
|
||||
String generatedName = null;
|
||||
|
||||
Exception e = null;
|
||||
@ -82,12 +83,11 @@ public class Codegen extends Interpreter {
|
||||
if (cx.getOptimizationLevel() > 0) {
|
||||
(new Optimizer()).optimize(tree, cx.getOptimizationLevel());
|
||||
}
|
||||
generatedName = generateCode(tree, classFiles, nameHelper);
|
||||
generatedName = generateCode(tree, names, classFiles, nameHelper);
|
||||
|
||||
Enumeration keys = classFiles.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String name = (String) keys.nextElement();
|
||||
byte[] classFile = (byte[]) classFiles.get(name);
|
||||
for (int i=0; i < names.size(); i++) {
|
||||
String name = (String) names.elementAt(i);
|
||||
byte[] classFile = (byte[]) classFiles.elementAt(i);
|
||||
if (nameHelper.getGeneratingDirectory() != null) {
|
||||
try {
|
||||
int lastDot = name.lastIndexOf('.');
|
||||
@ -367,11 +367,12 @@ public class Codegen extends Interpreter {
|
||||
|
||||
}
|
||||
|
||||
public String generateCode(Node tree, Hashtable results,
|
||||
public String generateCode(Node tree, Vector names, Vector classFiles,
|
||||
ClassNameHelper nameHelper)
|
||||
{
|
||||
this.itsNameHelper = (OptClassNameHelper) nameHelper;
|
||||
this.results = results;
|
||||
this.namesVector = names;
|
||||
this.classFilesVector = classFiles;
|
||||
Context cx = Context.getCurrentContext();
|
||||
itsSourceFile = null;
|
||||
if (cx.isGeneratingDebug())
|
||||
@ -523,7 +524,8 @@ public class Codegen extends Interpreter {
|
||||
}
|
||||
byte[] bytes = out.toByteArray();
|
||||
|
||||
results.put(name, bytes);
|
||||
namesVector.addElement(name);
|
||||
classFilesVector.addElement(bytes);
|
||||
classFile = null;
|
||||
|
||||
return name;
|
||||
@ -1394,7 +1396,9 @@ public class Codegen extends Interpreter {
|
||||
|
||||
Node def = (Node) fns.elementAt(i);
|
||||
Codegen codegen = new Codegen();
|
||||
String fnClassName = codegen.generateCode(def, results, itsNameHelper);
|
||||
String fnClassName = codegen.generateCode(def, namesVector,
|
||||
classFilesVector,
|
||||
itsNameHelper);
|
||||
|
||||
addByteCode(ByteCode.NEW, fnClassName);
|
||||
addByteCode(ByteCode.DUP);
|
||||
@ -4089,7 +4093,8 @@ if (true) {
|
||||
boolean inFunction;
|
||||
boolean inDirectCallFunction;
|
||||
private ClassFileWriter classFile;
|
||||
private Hashtable results;
|
||||
private Vector namesVector;
|
||||
private Vector classFilesVector;
|
||||
private short scriptRuntimeIndex;
|
||||
private int version;
|
||||
private OptClassNameHelper itsNameHelper;
|
||||
|
@ -72,7 +72,8 @@ public class Codegen extends Interpreter {
|
||||
ClassNameHelper nameHelper)
|
||||
throws IOException
|
||||
{
|
||||
Hashtable classFiles = new Hashtable(23);
|
||||
Vector classFiles = new Vector();
|
||||
Vector names = new Vector();
|
||||
String generatedName = null;
|
||||
|
||||
Exception e = null;
|
||||
@ -82,12 +83,11 @@ public class Codegen extends Interpreter {
|
||||
if (cx.getOptimizationLevel() > 0) {
|
||||
(new Optimizer()).optimize(tree, cx.getOptimizationLevel());
|
||||
}
|
||||
generatedName = generateCode(tree, classFiles, nameHelper);
|
||||
generatedName = generateCode(tree, names, classFiles, nameHelper);
|
||||
|
||||
Enumeration keys = classFiles.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String name = (String) keys.nextElement();
|
||||
byte[] classFile = (byte[]) classFiles.get(name);
|
||||
for (int i=0; i < names.size(); i++) {
|
||||
String name = (String) names.elementAt(i);
|
||||
byte[] classFile = (byte[]) classFiles.elementAt(i);
|
||||
if (nameHelper.getGeneratingDirectory() != null) {
|
||||
try {
|
||||
int lastDot = name.lastIndexOf('.');
|
||||
@ -367,11 +367,12 @@ public class Codegen extends Interpreter {
|
||||
|
||||
}
|
||||
|
||||
public String generateCode(Node tree, Hashtable results,
|
||||
public String generateCode(Node tree, Vector names, Vector classFiles,
|
||||
ClassNameHelper nameHelper)
|
||||
{
|
||||
this.itsNameHelper = (OptClassNameHelper) nameHelper;
|
||||
this.results = results;
|
||||
this.namesVector = names;
|
||||
this.classFilesVector = classFiles;
|
||||
Context cx = Context.getCurrentContext();
|
||||
itsSourceFile = null;
|
||||
if (cx.isGeneratingDebug())
|
||||
@ -523,7 +524,8 @@ public class Codegen extends Interpreter {
|
||||
}
|
||||
byte[] bytes = out.toByteArray();
|
||||
|
||||
results.put(name, bytes);
|
||||
namesVector.addElement(name);
|
||||
classFilesVector.addElement(bytes);
|
||||
classFile = null;
|
||||
|
||||
return name;
|
||||
@ -1394,7 +1396,9 @@ public class Codegen extends Interpreter {
|
||||
|
||||
Node def = (Node) fns.elementAt(i);
|
||||
Codegen codegen = new Codegen();
|
||||
String fnClassName = codegen.generateCode(def, results, itsNameHelper);
|
||||
String fnClassName = codegen.generateCode(def, namesVector,
|
||||
classFilesVector,
|
||||
itsNameHelper);
|
||||
|
||||
addByteCode(ByteCode.NEW, fnClassName);
|
||||
addByteCode(ByteCode.DUP);
|
||||
@ -4089,7 +4093,8 @@ if (true) {
|
||||
boolean inFunction;
|
||||
boolean inDirectCallFunction;
|
||||
private ClassFileWriter classFile;
|
||||
private Hashtable results;
|
||||
private Vector namesVector;
|
||||
private Vector classFilesVector;
|
||||
private short scriptRuntimeIndex;
|
||||
private int version;
|
||||
private OptClassNameHelper itsNameHelper;
|
||||
|
Loading…
x
Reference in New Issue
Block a user