[Biojava-dev] Bug report: getClassLoader() null return not handled

David Jung jungdl at ornl.gov
Wed May 5 21:26:43 EDT 2004


Hi.
I'm new to biojava and just starting to try it out.
Unfortunetely, I'm unable to use it because a handful of classes
have static constructors that throw null-pointer exceptions when
the type is loaded.

For example, code like:
SymbolList dna = DNATools.createDNA("atcggtcggctta");

(from the cookbook) throws a null-pointer exception.
I traced the problem to the following lines of code in the AlphabetManager:

      InputStream alphabetStream = 
AlphabetManager.class.getClassLoader().getResourceAsStream(
        "org/biojava/bio/symbol/AlphabetManager.xml"

The problem here is that a call is made to getClassLoader() which is 
then immediately used, without
checking for a null return value.  According to Sun's JDK1.4.x 
documentation for the
Class.getClassLoader() method:

/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.
/
Although when run from the .jar file in Sun's implementation, null isn't 
returned,
it would be more portable and correct if the case was tested for.
I'm trying to run biojava under Linux using the IKVM virtual machine.  
I've posted
to their list about the issue but it seems to be valid behaviour for a VM.
If the return is null, the static method 
ClassLoader.getSystemClassLoader() should
be used to get a class loader instead.
Making this change in AlphabetManager fixed that problem (only for it to get
to a similar case in RNATools.loadGeneticCode() )

I sould greatly appreciate if you could incorporate the fixes into you 
next version so
that I may use biojava.
Thanks.  (Biojava looks good from my reading of the tutorial/cookbook! btw.)
-David.





More information about the biojava-dev mailing list