OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: Java-Specific Question -- CORRECTION

[ Lists Home | Date Index | Thread Index ]
  • From: "Don Park" <donpark@quake.net>
  • To: "xml-dev Mailing List" <xml-dev@ic.ac.uk>
  • Date: Fri, 3 Apr 1998 20:25:02 -0800

This is a correction of my answer to David's question which is:

>>Here's a Java question.  Let's say that I have a class with a method
>>  public void parse (String publicId, String systemId, Reader reader)
>>    throws java.lang.Exception;
>>What will happen if the "java.io.Reader" class is not available on my
>>system (perhaps because I'm using a 1.0.2 browser), but I never invoke
>>this method (I'm assuming that I compiled my code under JDK 1.1 or JDK

I answered:

>ClassNotFoundException will be thrown when the class is loaded.  What you

This is wrong.  David reported test results to the contrary so I went back
to the VM spec and found that my understanding is either obsolete or wrong
to begin with.  Since the last thing I want to do is misinform, here is the
correct answer:

When a Java class is loaded, only the superclass and interfaces it
implements are 'resolved', meaning that they are loaded as well.  The class
is then 'verified'.  Verification of a class does not include checking
whether referenced classes, methods, fields actually exists.  After
verification, the class and its superclasses are 'initialized' and executed.

During execution, referenced classes are 'loaded' upon 'use'.  This means
that uninvoked methods can reference any class they want to as long as they
are available during compilation process.  Same is true for classes
referenced in unexecuted code path.

Therefore, following code could be used to write Reader aware SAX-client
which can run under Java 1.0:

        // if the exception is not thrown, the class is available so use the
        // Reader based method to parse.
    parser.parseReader(new java.io.InputStreamReader(in));
catch (ClassNotFoundException ex)
        // InputStreamReader is missing so use the stream-based method.

What I just described might not be true under just-in-time compilers and
server-side Java compilers depending on the compilation strategy involved.

I hope this corrects any misunderstanding due to my evil-twin's activities


Don Park

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS