GCJ and JDBC

Amir Bukhari ufz6@rz.uni-karlsruhe.de
Tue May 17 16:59:00 GMT 2005


Here is a simple program which use Constructor.newInstance. it work as it
expected in both JVM and GCJ (executable file)

######################################
public class DBManager {
	
	public DBManager() 
		initDB();
	}

	public void initDB() {
		try {
		    Class cls = String.class;
		    String st = (String)cls.newInstance();
		    st = st + "hallo gcj";
		    System.out.println(st);
		    //	try and create a java.sql.Statement so we can run
queries

		} catch (Exception e) {
			System.out.println("Error: " + e);
		}
	}

	

	public static void main(String[] args) {
	    DBManager db = new DBManager();
	    try {
            DBManager db1 =
(DBManager)DBManager.class.getConstructors()[0].newInstance(null);
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
	}
	
}

-----Original Message-----
From: java-owner@gcc.gnu.org [mailto:java-owner@gcc.gnu.org] On Behalf Of
Tom Tromey
Sent: Tuesday, May 17, 2005 6:18 PM
To: Amir Bukhari
Cc: java@gcc.gnu.org
Subject: Re: GCJ and JDBC

>>>>> "Amir" == Amir Bukhari <ufz6@rz.uni-karlsruhe.de> writes:

Amir> When I don't use HSQlDB (that mean my application has no JDBC)
Amir> then it work fine.

Based on the stack trace, my guess is that the code in
Constructor.newInstance that tries to find the caller's class is
failing.  You might be able to reproduce this with a smaller test
case that uses Constructor.newInstance.

Amir> Only one thing I
Amir> don't like, is that SWT application have dos console opened with
Amir> them!

Some Windows expert will need to answer this one.

Tom



More information about the Java mailing list