[icedtea-web] RFC: Add class checks to fail early on non-Oracle JDKs

Dr Andrew John Hughes ahughes at redhat.com
Mon Nov 1 08:42:58 PDT 2010


The attached patch makes configure fail if it can't find a number of
internal Sun classes that the plugin and NetX wrongly depend on.  This
makes the build fail early and clearly on non-Oracle JDKs rather than
attempting a build and hitting compile errors.

Over time, I expect the java.* classes to become available in GNU Classpath
and for those working on plugin and NetX to fix these issues with internal
code usage (which also produce warnings from javac during build).  Bugs
are filed under GNU Classpath and IcedTea as appropriate for these issues.

Ok for icedtea-web HEAD?

ChangeLog:

2010-10-28  Andrew John Hughes  <ahughes at redhat.com>

	* Makefile.am:
	(NETX_BOOTSTRAP_CLASSES): Removed.
	(PLUGIN_BOOTSTRAP_CLASSES): Likewise.
	(NETX_SUN_CLASSES): Likewise.
	(PLUGIN_SUN_CLASSES): Likewise.
	* acinclude.m4:
	(IT_CHECK_FOR_CLASS): Require detection
	of javac and java.  Put test class in
	sun.applet to get access to some internal
	classes.  Change test to use forName for
	the same reason.  I expect to be able to
	revert this when usage of sun.applet is fixed.
	(IT_FIND_JAVA): Ported from IcedTea6.  Change
	to prioritise 'java' over 'gij'.
	* configure.ac:
	Add IT_CHECK_FOR_CLASS checks for classes which
	are required but not found in JDKs other than
	Oracle-based ones.  Also check for java.* classes
	missing from current versions of gcj but which
	may appear there in future.

--
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
-------------- next part --------------
diff -r 3571cd24829e Makefile.am
--- a/Makefile.am	Thu Oct 28 16:18:36 2010 -0400
+++ b/Makefile.am	Mon Nov 01 15:34:18 2010 +0000
@@ -8,46 +8,6 @@
 # Build directories
 
 BOOT_DIR = $(abs_top_builddir)/bootstrap/jdk1.6.0
-
-# PR43578 - java.security.CodeSource.getCodeSigners() missing
-# PR43582 - Missing javax.swing.JTable.setFillsViewportHeight
-# PR43585 - java.security.KeyStore.TrustedCertificateEntry class missing
-NETX_BOOTSTRAP_CLASSES = \
-	$(SHARE)/java/security/CodeSource.java \
-	$(SHARE)/javax/swing/JTable.java \
-	$(SHARE)/java/security/KeyStore.java
-
-# PR46074 - Missing java.net cookie code required by IcedTea plugin
-PLUGIN_BOOTSTRAP_CLASSES = \
-	$(SHARE)/java/net/CookieManager.java \
-	$(SHARE)/java/net/HttpCookie.java \
-	$(SHARE)/java/net/CookieHandler.java
-
-# IT563 - NetX uses sun.security code
-# IT564 - NetX depends on sun.misc.BASE64Encoder
-# IT570 - NetX depends on sun.applet.AppletViewPanel
-# IT571 - NetX depends on com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager.java
-NETX_SUN_CLASSES = \
-	$(SHARE)/sun/security/provider/X509Factory.java \
-	$(SHARE)/sun/security/util/SecurityConstants.java \
-	$(SHARE)/sun/security/util/HostnameChecker.java \
-	$(SHARE)/sun/security/util/DerValue.java \
-	$(SHARE)/sun/security/x509/X500Name.java \
-	$(SHARE)/sun/misc/BASE64Encoder.java \
-	$(SHARE)/sun/applet/AppletViewerPanel.java \
-	$(SHARE)/sun/security/validator/ValidatorException.java \
-	$(SHARE)/com/sun/net/ssl/internal/ssl/X509ExtendedTrustManager.java
-
-# IT573 - Plugin depends on sun.awt,X11.XEmbeddedFrame.java
-# IT574 - Plugin depends on sun.misc.Ref
-# IT575 - Plugin depends on com.sun/jndi.toolkit.url.UrlUtil
-# IT576 - Plugin depends on sun.applet.AppletImageRef
-PLUGIN_SUN_CLASSES = \
-	$(SOLARIS)/sun/awt/X11/XEmbeddedFrame.java \
-	$(SHARE)/sun/misc/Ref.java \
-	$(SHARE)/com/sun/jndi/toolkit/url/UrlUtil.java \
-	$(SHARE)/sun/applet/AppletImageRef.java
-
 RUNTIME = $(BOOT_DIR)/jre/lib/rt.jar:$(BOOT_DIR)/jre/lib/jsse.jar
 
 # Flags
diff -r 3571cd24829e acinclude.m4
--- a/acinclude.m4	Thu Oct 28 16:18:36 2010 -0400
+++ b/acinclude.m4	Mon Nov 01 15:34:18 2010 +0000
@@ -302,19 +302,27 @@
 dnl is usually the name of the class with '.'
 dnl replaced by '_' and all letters capitalised.
 dnl e.g. IT_CHECK_FOR_CLASS([JAVA_UTIL_SCANNER],[java.util.Scanner])
+dnl Test class has to be in sun.applet for some internal classes
 AC_DEFUN([IT_CHECK_FOR_CLASS],[
-AC_CACHE_CHECK([if $2 is missing], it_cv_$1, [
-CLASS=Test.java
+AC_REQUIRE([IT_FIND_JAVAC])
+AC_REQUIRE([IT_FIND_JAVA])
+AC_CACHE_CHECK([if $2 is available], it_cv_$1, [
+CLASS=sun/applet/Test.java
 BYTECODE=$(echo $CLASS|sed 's#\.java##')
-mkdir tmp.$$
+mkdir -p tmp.$$/$(dirname $CLASS)
 cd tmp.$$
 cat << \EOF > $CLASS
 [/* [#]line __oline__ "configure" */
+package sun.applet;
+
+import $2;
+
 public class Test
 {
   public static void main(String[] args)
+    throws Exception
   {
-    $2.class.toString();
+    System.out.println(Class.forName("$2"));
   }
 }
 ]
@@ -331,7 +339,8 @@
 ])
 rm -f $CLASS *.class
 cd ..
-rmdir tmp.$$
+# should be rmdir but has to be rm -rf due to sun.applet usage
+rm -rf tmp.$$
 if test x"${it_cv_$1}" = "xno"; then
    AC_MSG_ERROR([$2 not found.])
 fi
@@ -507,3 +516,30 @@
   AC_SUBST(ARCH_PREFIX)
   AC_SUBST(ARCHFLAG)
 ])
+
+AC_DEFUN_ONCE([IT_FIND_JAVA],
+[
+  AC_MSG_CHECKING([for a Java virtual machine])
+  AC_ARG_WITH([java],
+              [AS_HELP_STRING(--with-java,specify location of the 1.5 java vm)],
+  [
+    JAVA="${withval}"
+  ],
+  [
+    JAVA=${SYSTEM_JDK_DIR}/bin/java
+  ])
+  if ! test -f "${JAVA}"; then
+    AC_PATH_PROG(JAVA, "${JAVA}")
+  fi
+  if test -z "${JAVA}"; then
+    AC_PATH_PROG(JAVA, "java")
+  fi
+  if test -z "${JAVA}"; then
+    AC_PATH_PROG(JAVA, "gij")
+  fi
+  if test -z "${JAVA}"; then
+    AC_MSG_ERROR("A 1.5-compatible Java VM is required.")
+  fi
+  AC_MSG_RESULT(${JAVA})
+  AC_SUBST(JAVA)
+])
diff -r 3571cd24829e configure.ac
--- a/configure.ac	Thu Oct 28 16:18:36 2010 -0400
+++ b/configure.ac	Mon Nov 01 15:34:18 2010 +0000
@@ -49,4 +49,32 @@
 AC_SUBST(X11_CFLAGS)
 AC_SUBST(X11_LIBS)
 
+dnl PR46074 (gcc) - Missing java.net cookie code required by IcedTea plugin
+dnl IT563 - NetX uses sun.security code
+dnl IT564 - NetX depends on sun.misc.BASE64Encoder
+dnl IT570 - NetX depends on sun.applet.AppletViewPanel
+dnl IT571 - NetX depends on com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager.java
+dnl IT573 - Plugin depends on sun.awt,X11.XEmbeddedFrame.java
+dnl IT574 - Plugin depends on sun.misc.Ref
+dnl IT575 - Plugin depends on com.sun/jndi.toolkit.url.UrlUtil
+dnl IT576 - Plugin depends on sun.applet.AppletImageRef
+
+IT_CHECK_FOR_CLASS(JAVA_UTIL_JAR_PACK200, [java.util.jar.Pack200])
+IT_CHECK_FOR_CLASS(JAVA_NET_COOKIEMANAGER, [java.net.CookieManager])
+IT_CHECK_FOR_CLASS(JAVA_NET_HTTPCOOKIE, [java.net.HttpCookie])
+IT_CHECK_FOR_CLASS(JAVA_NET_COOKIEHANDLER, [java.net.CookieHandler])
+IT_CHECK_FOR_CLASS(SUN_SECURITY_PROVIDER_X509FACTORY, [sun.security.provider.X509Factory])
+IT_CHECK_FOR_CLASS(SUN_SECURITY_UTIL_SECURITYCONSTANTS, [sun.security.util.SecurityConstants])
+IT_CHECK_FOR_CLASS(SUN_SECURITY_UTIL_HOSTNAMECHECKER, [sun.security.util.HostnameChecker])
+IT_CHECK_FOR_CLASS(SUN_SECURITY_X509_X500NAME, [sun.security.x509.X500Name])
+IT_CHECK_FOR_CLASS(SUN_MISC_BASE64ENCODER, [sun.misc.BASE64Encoder])
+IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETVIEWERPANEL, [sun.applet.AppletViewerPanel])
+IT_CHECK_FOR_CLASS(SUN_SECURITY_VALIDATOR_VALIDATOREXCEPTION, [sun.security.validator.ValidatorException])
+IT_CHECK_FOR_CLASS(COM_SUN_NET_SSL_INTERNAL_SSL_X509EXTENDEDTRUSTMANAGER,
+	[com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager])
+IT_CHECK_FOR_CLASS(SUN_AWT_X11_XEMBEDDEDFRAME, [sun.awt.X11.XEmbeddedFrame])
+IT_CHECK_FOR_CLASS(SUN_MISC_REF, [sun.misc.Ref])
+IT_CHECK_FOR_CLASS(COM_SUN_JNDI_TOOLKIT_URL_URLUTIL, [com.sun.jndi.toolkit.url.UrlUtil])
+IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef])
+
 AC_OUTPUT


More information about the distro-pkg-dev mailing list