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

[ Lists Home | Date Index | Thread Index ]
  • From: Andrew n marshall <amarshal@usc.edu>
  • To: "'David Megginson'" <ak117@freenet.carleton.ca>, "'xml-dev Mailing List'" <xml-dev@ic.ac.uk>
  • Date: Sat, 4 Apr 1998 00:24:57 -0800

On Friday, April 03, 1998 5:44 PM, David Megginson 
[SMTP:ak117@freenet.carleton.ca] wrote:
> 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
> 1.2)?

The JavaVM will throw a ClassNotFoundException because it will try to 
preload the class in case you do use the method.

> I'm becoming convinced that we need to support character streams in
> SAX, and I'm trying to figure out how to handle it in the Java
> version -- I think that I've worked out pretty much everything else
> now, except for a few minor details.

I'm dealing with a similar problem on an applet at work where I need to be 
able to support the Java Media Framework for sound if available.  My 
solution is to abstract everything that references the possibly missing 
classes into a second class, then in build an initialization routine like 
the following:

Class parserClass;  // used if creating several Parser objects
Parser parser = null;  // Parser is an abstract class or interface
                       // Used if only need one parser

void init() {
  try {
    Class.forName( "java.io.Reader" ); // checks if supported
    parserClass = Class.forName( "MyParserFor11" );
  } catch( ClassNotFoundException err ) {
    parserClass = Class.forName( "MyParserFor10" );
  try {
    parser = (Parser) parserClass.newInstance();
  } catch( InstantiationException err ) { // Constructor requires argument
  } catch( IllegalAccessException err ) { // Constructor isn't public

NOTE: Apparently my understandings reflected Don Park's >>original<< 
message which is apparently wrong.  But even so, the above will still work.

Andrew n marshall
  student - artist - programmer
      "Everyone a mentor,  Everyone a pupil"

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