Try Titlecase class name first when launching programs
On case insensitive filesystems like Mac OS X's HFS+ or Windows NTFS if Gerrit is started out of the classes directory through an IDE debugger we would find "daemon.class" on disk and try to load it, but the JVM refuses because "daemon" is not the actual class name, its "Daemon". Meanwhile running out of a JAR or on Linux always works, because the JAR and ext2/3/4 are case sensitive. Flip the order of operations around and try the Titlecase form of the command name first. Its more likely going to be a match for a Java classname, since developers name classes in CamelCaseFormat. Bug: issue 490 Change-Id: I43a487eb0d5d528ac370e1794a4542e412236307 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -118,12 +118,14 @@ public final class GerritLauncher {
|
||||
Class<?> clazz;
|
||||
try {
|
||||
try {
|
||||
clazz = Class.forName(pkg + "." + name, true, loader);
|
||||
String cn = name;
|
||||
if (cn.equals(cn.toLowerCase())) {
|
||||
cn = cn.substring(0, 1).toUpperCase() + cn.substring(1);
|
||||
}
|
||||
clazz = Class.forName(pkg + "." + cn, true, loader);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
if (name.equals(name.toLowerCase())) {
|
||||
String first = name.substring(0, 1).toUpperCase();
|
||||
String cn = first + name.substring(1);
|
||||
clazz = Class.forName(pkg + "." + cn, true, loader);
|
||||
clazz = Class.forName(pkg + "." + name, true, loader);
|
||||
} else {
|
||||
throw cnfe;
|
||||
}
|
||||
|
Reference in New Issue
Block a user