[libgda] Better handle GCJ as the java compiler



commit c09591d85b8a85f111ed117bdff332e31c72c769
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sat Mar 20 11:23:59 2010 +0100

    Better handle GCJ as the java compiler

 configure.in                 |   22 ++++++++--
 providers/jdbc/Makefile.am   |    2 +-
 providers/jdbc/derby.java    |    3 -
 providers/jdbc/h2.java       |   22 ++++-----
 providers/jdbc/meta.java     |   95 +++++++++++++++++++++---------------------
 providers/jdbc/provider.java |   14 +++----
 6 files changed, 82 insertions(+), 76 deletions(-)
---
diff --git a/configure.in b/configure.in
index e4db6da..b3d3707 100644
--- a/configure.in
+++ b/configure.in
@@ -1425,14 +1425,27 @@ then
 	       fi
 	  fi
 	  case "$JVERSION" in
-               JRE1.5.*) try_java=true;;
-               JRE1.6.*) try_java=true;;
+               JRE1.5.*)
+		try_java=true
+		JTYPE="Sun JRE 1.5"
+		JFLAGS="-Xlint:unchecked -Xlint:deprecation"
+		;;
+               JRE1.6.*)
+		try_java=true
+		JTYPE="Sun JRE 1.6"
+		JFLAGS="-Xlint:unchecked -Xlint:deprecation"
+		;;
+               JREgcj-4*)
+		try_java=true
+		JTYPE="GCJ"
+		JFLAGS=""
+		;;
                ECJ*) try_java=no;;
                *)
 	       ;;
 	  esac
 	  if test $try_java = true; then
-	     AC_MSG_RESULT([JAVA version Ok])
+	     AC_MSG_RESULT([JAVA version used is $JTYPE ])
 
 	     AC_MSG_CHECKING([for Java environment])
 	     ## retrieve JAVA_HOME from Java itself if not set
@@ -1560,6 +1573,7 @@ then
 	have_java=yes
 	AC_DEFINE(HAVE_JAVA, 1, [Have JAVA])
 	AC_SUBST(JAVA_LD_PATH)
+	AC_SUBST(JFLAGS)
 fi
 AM_CONDITIONAL(JAVA, test x$have_java = xyes)
 CFLAGS="$save_CFLAGS"
@@ -1835,7 +1849,7 @@ echo "      SQLite = yes `if test x$have_sqlite = xyes; then echo '(from system
 dnl echo "      Sybase = `if test x$sybasedir != x; then echo yes; else echo no; fi`"
 dnl echo "      xBase (dBase, Clipper, FoxPro) = `if test x$xbasedir != x; then echo yes; else echo no; fi`"
 dnl echo "      LDAP = `if test x$ldapdir != x; then echo yes; else echo no; fi`"
-echo "      JDBC = `if test x$have_java = xyes; then echo yes; else echo no; fi`"
+echo "      JDBC = `if test x$have_java = xyes; then echo "yes (using $JTYPE)"; else echo no; fi`"
 echo "      WEB = `if test x$have_libsoup = xyes; then echo yes; else echo no; fi`"
 if test x"$br_cv_binreloc" != "xyes" -a x"$platform_win32" != "xyes"
 then
diff --git a/providers/jdbc/Makefile.am b/providers/jdbc/Makefile.am
index f384348..6665fc2 100644
--- a/providers/jdbc/Makefile.am
+++ b/providers/jdbc/Makefile.am
@@ -84,7 +84,7 @@ jdbcprovdir = $(providerdir)
 jdbcprov_DATA = $(jdbcprov_jar)
 
 GdaJConnection.class: $(jdbcprov_sources)
-	$(JAVAC) -cp . -Xlint:unchecked -Xlint:deprecation -d $(top_builddir)/providers/jdbc $^
+	$(JAVAC) -cp . $(JFLAGS) -d $(top_builddir)/providers/jdbc $^
 
 $(jdbcprov_jar): $(jdbcprov_classes)
 	$(JAR) cfm $(jdbcprov_jar) $(top_srcdir)/providers/jdbc/MANIFEST.MF *.class
diff --git a/providers/jdbc/derby.java b/providers/jdbc/derby.java
index e5aba2d..d89c769 100644
--- a/providers/jdbc/derby.java
+++ b/providers/jdbc/derby.java
@@ -1,7 +1,4 @@
 import java.sql.*;
-import java.util.*;
-import java.io.*;
-
 
 class org_apache_derbyMeta extends GdaJMeta {
 	public org_apache_derbyMeta (Connection cnc) throws Exception {
diff --git a/providers/jdbc/h2.java b/providers/jdbc/h2.java
index 348514d..ab3b18b 100644
--- a/providers/jdbc/h2.java
+++ b/providers/jdbc/h2.java
@@ -1,6 +1,4 @@
 import java.sql.*;
-import java.util.*;
-import java.io.*;
 
 
 class org_h2_DriverMeta extends GdaJMeta {
@@ -60,25 +58,25 @@ class org_h2_DriverMetaTables extends GdaJMetaTables {
 
 		GdaJValue cv;
 		
-		cv = (GdaJValue) col_values.elementAt (0);
+		cv = col_values.elementAt (0);
 		cv.setCValue (rs, 0, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (1);
+		cv = col_values.elementAt (1);
 		cv.setCValue (rs, 1, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (2);
+		cv = col_values.elementAt (2);
 		cv.setCValue (rs, 2, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (3);
+		cv = col_values.elementAt (3);
 		cv.setCValue (rs, 3, c_pointer);
 		
-		cv = (GdaJValue) col_values.elementAt (5);
+		cv = col_values.elementAt (5);
 		cv.setCValue (rs, 4, c_pointer);
 
-		cv = (GdaJValue) col_values.elementAt (6);
+		cv = col_values.elementAt (6);
 		String ln = GdaJValue.toLower (rs.getString (2) + "." + rs.getString (3));
 		if (jm.schemaIsCurrent (rs.getString (2)))
 			cv.setCString (c_pointer, 6, GdaJValue.toLower (rs.getString (3)));
 		else
 			cv.setCString (c_pointer, 6, ln);
-		cv = (GdaJValue) col_values.elementAt (7);
+		cv = col_values.elementAt (7);
 		cv.setCString (c_pointer, 7, ln);
 
 		return true;
@@ -94,10 +92,10 @@ class org_h2_DriverMetaViews extends GdaJResultSet {
 	}
 
 	protected void columnTypesDeclared () {
-		GdaJValue cv = (GdaJValue) col_values.elementAt (0);
+		GdaJValue cv = col_values.elementAt (0);
 		cv.no_null = true;
 		cv.convert_lc = true;
-		((GdaJValue) col_values.elementAt (1)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (2)).convert_lc = true;
+		(col_values.elementAt (1)).convert_lc = true;
+		(col_values.elementAt (2)).convert_lc = true;
 	}
 }
diff --git a/providers/jdbc/meta.java b/providers/jdbc/meta.java
index 3f330b3..0252927 100644
--- a/providers/jdbc/meta.java
+++ b/providers/jdbc/meta.java
@@ -1,6 +1,5 @@
 import java.sql.*;
 import java.util.*;
-import java.io.*;
 
 /*
  * This class is the central point for meta data extraction. It is a default implementation for all JDBC providers
@@ -122,10 +121,10 @@ class GdaJMetaSchemas extends GdaJMetaResultSet {
 
 	protected void columnTypesDeclared () {
 		// the catalog part cannot be NULL, but "" instead
-		GdaJValue cv = (GdaJValue) col_values.elementAt (0);
+		GdaJValue cv = col_values.elementAt (0);
 		cv.no_null = true;
 		cv.convert_lc = true;
-		((GdaJValue) col_values.elementAt (1)).convert_lc = true;
+		(col_values.elementAt (1)).convert_lc = true;
 	}
 
 	public boolean fillNextRow (long c_pointer) throws Exception {
@@ -145,11 +144,11 @@ class GdaJMetaSchemas extends GdaJMetaResultSet {
 				return fillNextRow (c_pointer);
 		}
 
-		cv = (GdaJValue) col_values.elementAt (0);
+		cv = col_values.elementAt (0);
 		cv.setCValue (rs, 1, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (1);
+		cv = col_values.elementAt (1);
 		cv.setCValue (rs, 0, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (3);
+		cv = col_values.elementAt (3);
 		cv.setCBoolean (c_pointer, 3, false);
 
 		return true;
@@ -181,13 +180,13 @@ class GdaJMetaTables extends GdaJMetaResultSet {
 
 	protected void columnTypesDeclared () {
 		// the catalog part cannot be NULL, but "" instead
-		GdaJValue cv = (GdaJValue) col_values.elementAt (0);
+		GdaJValue cv = col_values.elementAt (0);
 		cv.no_null = true;
 		cv.convert_lc = true;
-		((GdaJValue) col_values.elementAt (1)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (2)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (6)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (7)).convert_lc = true;
+		(col_values.elementAt (1)).convert_lc = true;
+		(col_values.elementAt (2)).convert_lc = true;
+		(col_values.elementAt (6)).convert_lc = true;
+		(col_values.elementAt (7)).convert_lc = true;
 	}
 
 	public boolean fillNextRow (long c_pointer) throws Exception {
@@ -196,16 +195,16 @@ class GdaJMetaTables extends GdaJMetaResultSet {
 
 		GdaJValue cv;
 		
-		cv = (GdaJValue) col_values.elementAt (0);
+		cv = col_values.elementAt (0);
 		cv.setCValue (rs, 0, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (1);
+		cv = col_values.elementAt (1);
 		cv.setCValue (rs, 1, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (2);
+		cv = col_values.elementAt (2);
 		cv.setCValue (rs, 2, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (3);
+		cv = col_values.elementAt (3);
 		cv.setCValue (rs, 3, c_pointer);
 		
-		cv = (GdaJValue) col_values.elementAt (5);
+		cv = col_values.elementAt (5);
 		cv.setCValue (rs, 4, c_pointer);
 
 		String ln = GdaJValue.toLower (rs.getString (2) + "." + rs.getString (3));
@@ -213,7 +212,7 @@ class GdaJMetaTables extends GdaJMetaResultSet {
 			cv.setCString (c_pointer, 6, GdaJValue.toLower (rs.getString (3)));
 		else
 			cv.setCString (c_pointer, 6, ln);
-		cv = (GdaJValue) col_values.elementAt (7);
+		cv = col_values.elementAt (7);
 		cv.setCString (c_pointer, 7, ln);
 
 		return true;
@@ -242,11 +241,11 @@ class GdaJMetaViews extends GdaJMetaResultSet {
 
 	protected void columnTypesDeclared () {
 		// the catalog part cannot be NULL, but "" instead
-		GdaJValue cv = (GdaJValue) col_values.elementAt (0);
+		GdaJValue cv = col_values.elementAt (0);
 		cv.no_null = true;
 		cv.convert_lc = true;
-		((GdaJValue) col_values.elementAt (1)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (2)).convert_lc = true;
+		(col_values.elementAt (1)).convert_lc = true;
+		(col_values.elementAt (2)).convert_lc = true;
 	}
 
 	public boolean fillNextRow (long c_pointer) throws Exception {
@@ -255,11 +254,11 @@ class GdaJMetaViews extends GdaJMetaResultSet {
 
 		GdaJValue cv;
 		
-		cv = (GdaJValue) col_values.elementAt (0);
+		cv = col_values.elementAt (0);
 		cv.setCValue (rs, 0, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (1);
+		cv = col_values.elementAt (1);
 		cv.setCValue (rs, 1, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (2);
+		cv = col_values.elementAt (2);
 		cv.setCValue (rs, 2, c_pointer);
 
 		return true;
@@ -307,19 +306,19 @@ class GdaJMetaColumns extends GdaJMetaResultSet {
 
 	protected void columnTypesDeclared () {
 		// the catalog part cannot be NULL, but "" instead
-		GdaJValue cv = (GdaJValue) col_values.elementAt (0);
+		GdaJValue cv = col_values.elementAt (0);
 		cv.no_null = true;
 		cv.convert_lc = true;
-		((GdaJValue) col_values.elementAt (1)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (2)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (3)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (7)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (15)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (16)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (17)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (18)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (19)).convert_lc = true;
-		((GdaJValue) col_values.elementAt (20)).convert_lc = true;
+		(col_values.elementAt (1)).convert_lc = true;
+		(col_values.elementAt (2)).convert_lc = true;
+		(col_values.elementAt (3)).convert_lc = true;
+		(col_values.elementAt (7)).convert_lc = true;
+		(col_values.elementAt (15)).convert_lc = true;
+		(col_values.elementAt (16)).convert_lc = true;
+		(col_values.elementAt (17)).convert_lc = true;
+		(col_values.elementAt (18)).convert_lc = true;
+		(col_values.elementAt (19)).convert_lc = true;
+		(col_values.elementAt (20)).convert_lc = true;
 	}
 
 	public boolean fillNextRow (long c_pointer) throws Exception {
@@ -327,29 +326,29 @@ class GdaJMetaColumns extends GdaJMetaResultSet {
 			return false;
 
 		GdaJValue cv;
-		int i, r;
-
-		((GdaJValue) col_values.elementAt (0)).setCValue (rs, 0, c_pointer);
-		((GdaJValue) col_values.elementAt (1)).setCValue (rs, 1, c_pointer);
-		((GdaJValue) col_values.elementAt (2)).setCValue (rs, 2, c_pointer);
-		((GdaJValue) col_values.elementAt (3)).setCValue (rs, 3, c_pointer);
-		((GdaJValue) col_values.elementAt (4)).setCValue (rs, 16, c_pointer);
-		((GdaJValue) col_values.elementAt (5)).setCValue (rs, 12, c_pointer);
-		cv = (GdaJValue) col_values.elementAt (6);
+		int i;
+
+		(col_values.elementAt (0)).setCValue (rs, 0, c_pointer);
+		(col_values.elementAt (1)).setCValue (rs, 1, c_pointer);
+		(col_values.elementAt (2)).setCValue (rs, 2, c_pointer);
+		(col_values.elementAt (3)).setCValue (rs, 3, c_pointer);
+		(col_values.elementAt (4)).setCValue (rs, 16, c_pointer);
+		(col_values.elementAt (5)).setCValue (rs, 12, c_pointer);
+		cv = col_values.elementAt (6);
 		i = rs.getInt (10);
 		if (i == DatabaseMetaData.columnNoNulls)
 			cv.setCBoolean (c_pointer, 6, false);
 		else
 			cv.setCBoolean (c_pointer, 6, true);
-		((GdaJValue) col_values.elementAt (7)).setCValue (rs, 5, c_pointer);
+		(col_values.elementAt (7)).setCValue (rs, 5, c_pointer);
 
-		((GdaJValue) col_values.elementAt (9)).setCString (c_pointer, 9, 
+		(col_values.elementAt (9)).setCString (c_pointer, 9, 
 								   GdaJValue.jdbc_type_to_g_type (rs.getInt (5))); // gtype
 
-		((GdaJValue) col_values.elementAt (11)).setCValue (rs, 15, c_pointer);
-		((GdaJValue) col_values.elementAt (12)).setCValue (rs, 8, c_pointer); // numeric_precision
+		(col_values.elementAt (11)).setCValue (rs, 15, c_pointer);
+		(col_values.elementAt (12)).setCValue (rs, 8, c_pointer); // numeric_precision
 
-		((GdaJValue) col_values.elementAt (23)).setCValue (rs, 11, c_pointer); // comments
+		(col_values.elementAt (23)).setCValue (rs, 11, c_pointer); // comments
 
 		return true;
 	}
diff --git a/providers/jdbc/provider.java b/providers/jdbc/provider.java
index 3e40f2c..94e41ed 100644
--- a/providers/jdbc/provider.java
+++ b/providers/jdbc/provider.java
@@ -188,7 +188,7 @@ class GdaJConnection {
 			throw new Exception ("No transaction started");
 		}
 
-		svp = (Savepoint) svp_map.get (svp_name);
+		svp = svp_map.get (svp_name);
 		if (svp != null) {
 			throw new Exception ("Savepoint '" + svp_name + "' already exists");
 		}
@@ -201,7 +201,7 @@ class GdaJConnection {
 		if (cnc.getAutoCommit() == true) {
 			throw new Exception ("No transaction started");
 		}
-		svp = (Savepoint) svp_map.get (svp_name);
+		svp = svp_map.get (svp_name);
 		if (svp == null) {
 			throw new Exception ("No savepoint '" + svp_name + "' found");
 		}
@@ -214,7 +214,7 @@ class GdaJConnection {
 		if (cnc.getAutoCommit() == true) {
 			throw new Exception ("No transaction started");
 		}
-		svp = (Savepoint) svp_map.get (svp_name);
+		svp = svp_map.get (svp_name);
 		if (svp == null) {
 			throw new Exception ("No savepoint '" + svp_name + "' found");
 		}
@@ -292,7 +292,7 @@ class GdaJPStmt {
 	// sets a parameter's value
 	// if c_value_pointer is 0, then the parameter should be set to NULL
 	public void setParameterValue (int index, long c_value_pointer) throws Exception {
-		GdaJValue cv = (GdaJValue) param_values.elementAt (index);
+		GdaJValue cv = param_values.elementAt (index);
 		cv.getCValue (ps, index, c_value_pointer);
 	}
 
@@ -440,7 +440,7 @@ class GdaJResultSet {
 		if (! rs.next ())
 			return false;
 		for (i = 0; i < ncols; i++) {
-			GdaJValue cv = (GdaJValue) col_values.elementAt (i);
+			GdaJValue cv = col_values.elementAt (i);
 			cv.setCValue (rs, i, c_pointer);
 		}
 		return true;
@@ -890,7 +890,7 @@ class GdaJBlob extends GdaJValue {
 		else {
 			GdaInputStream is;
 			is = getCBlob (c_pointer);
-			ps.setBinaryStream (index + 1, is, is.size);
+			ps.setBinaryStream (index + 1, is, (int) is.size);
 		}
 	}
 }
@@ -1038,12 +1038,10 @@ class GdaInputStream extends InputStream {
 	static int chunk_size = 65536; // 64kb chunks
 
 	private static native void initIDs();
-	private native int[] readData (long gda_blob_pointer, long offset, long size);
 	private native byte[] readByteData (long gda_blob_pointer, long offset, long size);
 	public long size;
 	private long current_pos;
 	private long gda_blob_pointer;
-	private byte[] data;
 
 	private InputStream ist = null; // delegate
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]