This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: gij support for slashes in class names
Here is an alternate patch to enable "/" separators on the gij command line.
It also changes MainThread to not chain ClassNotFoundExceptions to the
NoClassDefFoundError that it throws. This reduces the excessive stack
trace printed when an invalid class argument is given, bringing us
closer to other VM's behavior.
This stack trace was occasionally useful in the past because
ClassNotFoundExceptions could sometimes be thrown for other reasons
(such as a missing dependent class). However, the cases where that could
happen should all now be fixed for interpreted and BC classes - such
exceptions are properly deferred and any NoClassDefFoundError thrown
from here is for the same reason, so printing a full stack trace is
unnecessary.
I'm checking this in to trunk.
Bryce
2006-05-31 Bryce McKinlay <mckinlay@redhat.com>
* prims.cc (_Jv_RunMain): Use JvNewStringUTF for command-line class
name, not Latin1.
* gnu/java/lang/MainThread.java (run): Allow file separator char to
be used in place of '.' as class-name separator. Don't chain
ClassNotFoundException.
Index: prims.cc
===================================================================
--- prims.cc (revision 114274)
+++ prims.cc (working copy)
@@ -1524,7 +1524,7 @@
if (klass)
main_thread = new MainThread (klass, arg_vec);
else
- main_thread = new MainThread (JvNewStringLatin1 (name),
+ main_thread = new MainThread (JvNewStringUTF (name),
arg_vec, is_jar);
}
catch (java::lang::Throwable *t)
Index: gnu/java/lang/MainThread.java
===================================================================
--- gnu/java/lang/MainThread.java (revision 114274)
+++ gnu/java/lang/MainThread.java (working copy)
@@ -39,6 +39,7 @@
package gnu.java.lang;
+import java.io.File;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
@@ -91,13 +92,14 @@
{
try
{
- klass = Class.forName(klass_name, true,
- ClassLoader.getSystemClassLoader());
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ // Permit main class name to be specified in file-system format.
+ klass_name = klass_name.replace(File.separatorChar, '.');
+ klass = cl.loadClass(klass_name);
}
catch (ClassNotFoundException x)
{
NoClassDefFoundError ncdfe = new NoClassDefFoundError(klass_name);
- ncdfe.initCause(x);
throw ncdfe;
}
}