This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
[4.8 Regression] gjavah throws an exception
- From: Andrew Haley <aph at redhat dot com>
- To: classpath-patches <classpath-patches at gnu dot org>, "java at gcc dot gnu dot org" <java at gcc dot gnu dot org>
- Date: Mon, 17 Dec 2012 15:39:09 +0000
- Subject: [4.8 Regression] gjavah throws an exception
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55716
This bug is caused by http://cvs.savannah.gnu.org/viewvc/classpath/tools/gnu/classpath/tools/javah/Main.java?root=classpath&r1=1.13&r2=1.14
Automagic handling of inner classes was added, but in a bogus way.
If a class has inner classes, those inner classes are searched on
the classpath. This is wrong if the argument to javah is a filename:
the inner class may not exist on the classpath, and even if they do
they will be the wrong versions.
IMO, if given filenames gjavah should not search for inner classes
at all. This patch does so.
I have another patch that finds the correct inner class files for a
a class, but this is better. As a whitespace diff it is simply
Index: Main.java
===================================================================
--- Main.java (revision 194553)
+++ Main.java (working copy)
@@ -370,6 +370,8 @@
results.put(filename, klass);
parsed.add(item.toString());
+ if (! (item instanceof File))
+ {
// Check to see if there are inner classes to also parse
Iterator<?> innerClasses = klass.innerClasses.iterator();
HashSet<Object> innerNames = new HashSet<Object>();
@@ -381,6 +383,7 @@
}
results.putAll(parseClasses(innerNames.iterator()));
}
+ }
return results;
}
Andrew.
2012-12-17 Andrew Haley <aph@redhat.com>
* tools/gnu/classpath/tools/javah/Main.java (parseClasses): Dont
scan inner classes if our item is a file.
Index: Main.java
===================================================================
--- Main.java (revision 194553)
+++ Main.java (working copy)
@@ -370,16 +370,19 @@
results.put(filename, klass);
parsed.add(item.toString());
- // Check to see if there are inner classes to also parse
- Iterator<?> innerClasses = klass.innerClasses.iterator();
- HashSet<Object> innerNames = new HashSet<Object>();
- while (innerClasses.hasNext())
+ if (! (item instanceof File))
{
- String innerName = ((InnerClassNode) innerClasses.next()).name;
- if (!parsed.contains(innerName))
- innerNames.add(innerName);
+ // Check to see if there are inner classes to also parse
+ Iterator<?> innerClasses = klass.innerClasses.iterator();
+ HashSet<Object> innerNames = new HashSet<Object>();
+ while (innerClasses.hasNext())
+ {
+ String innerName = ((InnerClassNode) innerClasses.next()).name;
+ if (!parsed.contains(innerName))
+ innerNames.add(innerName);
+ }
+ results.putAll(parseClasses(innerNames.iterator()));
}
- results.putAll(parseClasses(innerNames.iterator()));
}
return results;
}