This is the mail archive of the kawa@sourceware.cygnus.com mailing list for the Kawa project. See the Kawa home page for more information.
I wrote a very simple program to test out the class loader/saver: ********** TestDump.java ********* import java.lang.*; import gnu.bytecode.*; import java.io.*; public class TestDump { public static void main(String[] args) { FileInputStream sourceFileInputStream; try { sourceFileInputStream = new FileInputStream(args[0]); ClassType ct = ClassFileInput.readClassType(sourceFileInputStream); ct.writeToFile(args[0] + ".copy"); } catch (IOException e) { e.printStackTrace(); } } } ***************** End of TestDump.java ********** Compiled this and ran it with one of my classfiles. Got an error: java.lang.NullPointerException at gnu.bytecode.ClassType.doFixups(ClassType.java:273) at gnu.bytecode.ClassType.writeToStream(ClassType.java:284) at gnu.bytecode.ClassType.writeToFile(ClassType.java:324) at TestDump.main(TestDump.java:12) A little digging around showed that the code snippet (lines 270--273) in gnu.bytecode.ClassType.java don't check for (code == null). So I added a check shown below and I was able to use the copy in place of the real class file with no problems. Can someone explain if this is a bug? Thanks. for (Method method = methods; method != null && method.code!=null; method = method.next) { ^^^^^^^^^^^^^^^^^^^^^^^ method.assign_constants (); method.code.finalize_labels (); } ________________________________________________________________ B. Narasimhan naras@stat.stanford.edu http://www-stat.stanford.edu/~naras