This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

disassemble throws NPE with system classes


Calling disassemble on system class methods like Math#asin or
Object#toString will currently throw a NPE (at least it will with Oracle
Java 1.7.0_40):

#|kawa:1|# (disassemble java.lang.Math:asin)
java.lang.NullPointerException
	at gnu.expr.PrimProcedure.disassemble(PrimProcedure.java:1016)
	at gnu.expr.PrimProcedure.disassemble(PrimProcedure.java:975)
	at gnu.expr.PrimProcedure.disassemble$X(PrimProcedure.java:969)
	at kawa.lib.trace.disassemble(trace.scm:22)
	at atInteractiveLevel$73.run(stdin:74)
	at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:309)
	at gnu.expr.ModuleExp.evalModule(ModuleExp.java:210)
	at kawa.Shell.run(Shell.java:279)
	at kawa.Shell.run(Shell.java:194)
	at kawa.Shell.run(Shell.java:175)
	at kawa.repl.main(repl.java:871)


This happens because Class#getClassLoader() returns null to represent
the bootstrap class loader:

> Returns the class loader for the class. Some implementations may use
> null to represent the bootstrap class loader. This method will return
> null in such implementations if this class was loaded by the bootstrap
> class loader.

- http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getClassLoader()


Inserting a line

	if (loader == null) loader = ClassLoader.getSystemClassLoader();

in PrimProcedure#disassemble(Procedure,ClassTypeWriter)
seems to fix it:


#|kawa:1|# (disassemble java.lang.Object:toString)
In class java.lang.Object at jar:file:/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/rt.jar!/java/lang/Object.class

Method name:"toString" public Signature: ()java.lang.String
Attribute "Code", length:60, max_stack:2, max_locals:1, code_length:36
[snip]


Patch attached.

--
Jamison Hope
The PTR Group
www.theptrgroup.com


Attachment: fix-disassemble-npe.diff
Description: Binary data

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]