This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ecj] Patch: FYI: merge in Classpath 0.93+


I'm checking this in on the gcj-eclipse-merge-branch.

This merges in Classpath 0.93+.

I tagged Classpath cvs trunk with 'libgcj-import-20061211' and I
imported the result into the classpath-generics maintainer branch.
Then I merged this over to the gcj-eclipse-merge-branch.  Note that we
needed Classpath trunk and not 0.93, because we wanted to pick up the
ASM changes, which went in after the release.

The appended patch only shows selected bits -- I left out the merge
itself, all the .h and .class file changes, and some new override
files.

Upstream changed a few VM APIs.  Rather than deal with rewriting this
support during the merge, I took a simpler exit and pulled in .java
files from the previous Classpath.  In particular, java.io, java.net,
and gnu.java.nio were affected.  We can address these problems
"later".

Andrew, Gary -- please take a look at the new
VMStackWalker.firstNonNullClassLoader.  I copied this in from upstream.

Finally, with this import we will be able to build the tools again.
I will fix this in a followup patch.

This does reasonably well on the test suite.  There are a few test
suite bugs that look like leftovers from the trunk->branch merge,
nothing major.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* sources.am, Makefile.in: Rebuilt.
	* gnu/java/nio/FileLockImpl.java: New override.
	* gnu/java/nio/SelectorProviderImpl.java: New override.
	* gnu/java/nio/PipeImpl.java: New override.
	* gnu/java/nio/SocketChannelSelectionKeyImpl.java: New override.
	* gnu/java/nio/NIOSocket.java: New override.
	* gnu/java/nio/SocketChannelSelectionKey.java: New override.
	* java/io/FileDescriptor.java: New override.
	* java/io/RandomAccessFile.java: New override.
	* java/io/FileInputStream.java: New override.
	* java/io/FileOutputStream.java: New override.
	* configure.ac: Pass --disable-Werror, --disable-tool-wrappers to
	Classpath configure.
	* java/io/ObjectInputStream.java (readClassDescriptor): Don't pass
	class loader to ObjectStreamField.
	* java/net/DatagramSocket.java: New override.
	* java/net/Socket.java: New override.
	* java/net/MulticastSocket.java: New override.
	* gnu/classpath/VMStackWalker.java (firstNonNullClassLoader): New
	method from Classpath.
	* java/lang/Class.java (newInstance): Fixed return type.
	(forName): Likewise.
	(getClasses): Likewise.
	(getComponentType): Likewise.
	(getConstructors): Likewise.
	(getDeclaredClasses): Likewise.
	(getDeclaredConstructors): Likewise.
	(getDeclaringClass): Likewise.
	(getInterfaces): Likewise.
	(getSuperclass): Likewise.
	(internalGetClasses): Genericized.
	(getMethod): Likewise.
	(isAssignableFrom): Likewise.
	* java/util/zip/natDeflater.cc (getBytesWritten): Renamed.
	(getBytesRead): Likewise.
	* java/util/zip/Deflater.java (getBytesRead, getBytesWritten): New
	methods.
	(getTotalIn, getTotalOut): Rewrote.
	* java/net/NetworkInterface.java: New override.
	* java/lang/ClassLoader.java (defineClass): New overload from
	Classpath.

Index: configure.ac
===================================================================
--- configure.ac	(revision 119668)
+++ configure.ac	(working copy)
@@ -119,7 +119,6 @@
 # (5) For libstdc++-v3, -fno-builtin must be present here so that a
 # non-conflicting form of std::exit can be guessed by AC_PROG_CXX, and
 # used in later tests.  This may not be necessary in libjava; I don't know.
-m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
 m4_define([_AC_ARG_VAR_PRECIOUS],[])
 save_CXXFLAGS="$CXXFLAGS"
@@ -383,7 +382,8 @@
 # Set up to configure Classpath.
 # FIXME: no supported way to pass args in autoconf.
 ac_configure_args="$ac_configure_args --with-fastjar=$JAR"
-ac_configure_args="$ac_configure_args --enable-tool-wrappers"
+# Disable tool wrappers to avoid ltdl.h configure check.
+ac_configure_args="$ac_configure_args --disable-tool-wrappers"
 ac_configure_args="$ac_configure_args --disable-load-library"
 ac_configure_args="$ac_configure_args --${LIBGCJDEBUG}-debug"
 ac_configure_args="$ac_configure_args --enable-default-toolkit=$TOOLKIT"
@@ -420,6 +420,8 @@
     ac_configure_args="$ac_configure_args --with-escher=$with_escher"
   fi
 fi
+# -Werror causes unavoidable problems in code using alsa.
+ac_configure_args="$ac_configure_args --disable-Werror"
 dnl --with-gcj=$GCJ
 dnl --with-javah=$GCJH
 dnl gjdoc?
Index: java/io/ObjectInputStream.java
===================================================================
--- java/io/ObjectInputStream.java	(revision 119668)
+++ java/io/ObjectInputStream.java	(working copy)
@@ -1,5 +1,5 @@
 /* ObjectInputStream.java -- Class used to read serialized objects
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
    Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -540,7 +540,7 @@
 	  class_name = String.valueOf(type_code);
 		  
 	fields[i] =
-	  new ObjectStreamField(field_name, class_name, callersClassLoader);
+	  new ObjectStreamField(field_name, class_name);
       }
 	      
     /* Now that fields have been read we may resolve the class
Index: gnu/classpath/VMStackWalker.java
===================================================================
--- gnu/classpath/VMStackWalker.java	(revision 119668)
+++ gnu/classpath/VMStackWalker.java	(working copy)
@@ -134,5 +134,21 @@
    * is here to work around access permissions.
    */
   public static native ClassLoader getClassLoader(Class cl);
+
+  /**
+   * Walk up the stack and return the first non-null class loader.
+   * If there aren't any non-null class loaders on the stack, return null.
+   */
+  public static ClassLoader firstNonNullClassLoader()
+  {
+    Class[] stack = getClassContext();
+    for (int i = 0; i < stack.length; i++)
+      {
+        ClassLoader loader = getClassLoader(stack[i]);
+        if (loader != null)
+          return loader;
+      }
+    return null;
+  }
 }
 
Index: java/lang/Class.java
===================================================================
--- java/lang/Class.java	(revision 119668)
+++ java/lang/Class.java	(working copy)
@@ -119,7 +119,7 @@
    * @throws ExceptionInInitializerError if the class loads, but an exception
    *         occurs during initialization
    */
-  public static native Class forName (String className)
+  public static native Class<?> forName (String className)
     throws ClassNotFoundException;
 
   // A private internal method that is called by compiler-generated code.
@@ -154,8 +154,8 @@
    * @see ClassLoader
    * @since 1.2
    */
-  public static native Class forName (String className, boolean initialize,
-				      ClassLoader loader)
+  public static native Class<?> forName (String className, boolean initialize,
+					 ClassLoader loader)
     throws ClassNotFoundException;
   
   /**
@@ -170,7 +170,7 @@
    * @throws SecurityException if the security check fails
    * @since 1.1
    */
-  public Class[] getClasses()
+  public Class<?>[] getClasses()
   {
     memberAccessCheck(Member.PUBLIC);
     return internalGetClasses();
@@ -179,16 +179,16 @@
   /**
    * Like <code>getClasses()</code> but without the security checks.
    */
-  private Class[] internalGetClasses()
+  private Class<?>[] internalGetClasses()
   {
-    ArrayList list = new ArrayList();
+    ArrayList<Class> list = new ArrayList<Class>();
     list.addAll(Arrays.asList(getDeclaredClasses(true)));
     Class superClass = getSuperclass();
     if (superClass != null)
       list.addAll(Arrays.asList(superClass.internalGetClasses()));
-    return (Class[])list.toArray(new Class[list.size()]);
+    return list.toArray(new Class<?>[list.size()]);
   }
-  
+
   /**
    * Get the ClassLoader that loaded this class.  If the class was loaded
    * by the bootstrap classloader, this method will return null.
@@ -223,7 +223,7 @@
    * @see Array
    * @since 1.1
    */
-  public native Class getComponentType ();
+  public native Class<?> getComponentType ();
 
   /**
    * Get a public constructor declared in this class. If the constructor takes
@@ -239,7 +239,7 @@
    * @see #getConstructors()
    * @since 1.1
    */
-  public native Constructor<T> getConstructor(Class... args)
+  public native Constructor<T> getConstructor(Class<?>... args)
     throws NoSuchMethodException;
 
   /**
@@ -254,7 +254,7 @@
    * @throws SecurityException if the security check fails
    * @since 1.1
    */
-  public Constructor[] getConstructors()
+  public Constructor<?>[] getConstructors()
   {
     memberAccessCheck(Member.PUBLIC);
     return getDeclaredConstructors(true);
@@ -274,7 +274,7 @@
    * @see #getDeclaredConstructors()
    * @since 1.1
    */
-  public native Constructor<T> getDeclaredConstructor(Class... args)
+  public native Constructor<T> getDeclaredConstructor(Class<?>... args)
     throws NoSuchMethodException;
 
   /**
@@ -289,13 +289,13 @@
    * @throws SecurityException if the security check fails
    * @since 1.1
    */
-  public Class[] getDeclaredClasses()
+  public Class<?>[] getDeclaredClasses()
   {
     memberAccessCheck(Member.DECLARED);
     return getDeclaredClasses(false);
   }
 
-  native Class[] getDeclaredClasses (boolean publicOnly);
+  native Class<?>[] getDeclaredClasses (boolean publicOnly);
 
   /**
    * Get all the declared constructors of this class. This returns an array of
@@ -309,13 +309,13 @@
    * @throws SecurityException if the security check fails
    * @since 1.1
    */
-  public Constructor[] getDeclaredConstructors()
+  public Constructor<?>[] getDeclaredConstructors()
   {
     memberAccessCheck(Member.DECLARED);
     return getDeclaredConstructors(false);
   }
 
-  native Constructor[] getDeclaredConstructors (boolean publicOnly);
+  native Constructor<?>[] getDeclaredConstructors (boolean publicOnly);
 
   /**
    * Get a field declared in this class, where name is its simple name. The
@@ -376,7 +376,7 @@
    * @see #getDeclaredMethods()
    * @since 1.1
    */
-  public Method getDeclaredMethod(String methodName, Class... args)
+  public Method getDeclaredMethod(String methodName, Class<?>... args)
     throws NoSuchMethodException
   {
     memberAccessCheck(Member.DECLARED);
@@ -416,7 +416,7 @@
    * @since 1.1
    */
   // This is marked as unimplemented in the JCL book.
-  public native Class getDeclaringClass ();
+  public native Class<?> getDeclaringClass ();
 
   private native Field getField (String fieldName, int hash)
     throws NoSuchFieldException;
@@ -505,7 +505,7 @@
    *
    * @return the interfaces this class directly implements
    */
-  public native Class[] getInterfaces ();
+  public native Class<?>[] getInterfaces ();
 
   private final native void getSignature(StringBuffer buffer);
   private static final native String getSignature(Class[] args,
@@ -535,7 +535,7 @@
    * @see #getMethods()
    * @since 1.1
    */
-  public Method getMethod(String methodName, Class... args)
+  public Method getMethod(String methodName, Class<?>... args)
     throws NoSuchMethodException
   {
     memberAccessCheck(Member.PUBLIC);
@@ -708,7 +708,7 @@
    *
    * @return the direct superclass of this class
    */
-  public native Class getSuperclass ();
+  public native Class<? super T> getSuperclass ();
   
   /**
    * Return whether this class is an array type.
@@ -732,7 +732,7 @@
    * @throws NullPointerException if c is null
    * @since 1.1
    */
-  public native boolean isAssignableFrom (Class c);
+  public native boolean isAssignableFrom (Class<?> c);
  
   /**
    * Discover whether an Object is an instance of this Class.  Think of it
@@ -790,7 +790,7 @@
    * @throws ExceptionInInitializerError if class initialization caused by
    *         this call fails with an exception
    */
-  public native Object newInstance ()
+  public native T newInstance ()
     throws InstantiationException, IllegalAccessException;
 
   // We need a native method to retrieve the protection domain, because we
Index: java/util/zip/Deflater.java
===================================================================
--- java/util/zip/Deflater.java	(revision 119668)
+++ java/util/zip/Deflater.java	(working copy)
@@ -174,14 +174,34 @@
   /** 
    * Gets the number of input bytes processed so far.
    */
-  public native int getTotalIn();
+  @Deprecated
+  public int getTotalIn()
+  {
+    return (int) getBytesRead();
+  }
 
   /** 
+   * Gets the number of input bytes processed so far.
+   * @since 1.5
+   */
+  public native long getBytesRead();
+
+  /** 
    * Gets the number of output bytes so far.
    */
-  public native int getTotalOut();
+  @Deprecated
+  public int getTotalOut()
+  {
+    return (int) getBytesWritten();
+  }
 
   /** 
+   * Gets the number of output bytes so far.
+   * @since 1.5
+   */
+  public native long getBytesWritten();
+
+  /** 
    * Finalizes this object.
    */
   protected void finalize()
Index: java/util/zip/natDeflater.cc
===================================================================
--- java/util/zip/natDeflater.cc	(revision 119668)
+++ java/util/zip/natDeflater.cc	(working copy)
@@ -1,6 +1,6 @@
 // natDeflater.cc - Implementation of Deflater native methods.
 
-/* Copyright (C) 1999, 2002  Free Software Foundation
+/* Copyright (C) 1999, 2002, 2006  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -93,16 +93,16 @@
   return s->adler;
 }
 
-jint
-java::util::zip::Deflater::getTotalIn ()
+jlong
+java::util::zip::Deflater::getBytesRead ()
 {
   JvSynchronize sync (this);
   z_streamp s = (z_streamp) zstream;
   return s->total_in;
 }
 
-jint
-java::util::zip::Deflater::getTotalOut ()
+jlong
+java::util::zip::Deflater::getBytesWritten ()
 {
   JvSynchronize sync (this);
   z_streamp s = (z_streamp) zstream;
Index: java/lang/ClassLoader.java
===================================================================
--- java/lang/ClassLoader.java	(revision 119668)
+++ java/lang/ClassLoader.java	(working copy)
@@ -46,6 +46,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.nio.ByteBuffer;
 import java.security.CodeSource;
 import java.security.PermissionCollection;
 import java.security.Policy;
@@ -488,6 +489,35 @@
   }
 
   /**
+   * Helper to define a class using the contents of a byte buffer. If
+   * the domain is null, the default of
+   * <code>Policy.getPolicy().getPermissions(new CodeSource(null,
+   * null))</code> is used. Once a class has been defined in a
+   * package, all further classes in that package must have the same
+   * set of certificates or a SecurityException is thrown.
+   *
+   * @param name the name to give the class.  null if unknown
+   * @param buf a byte buffer containing bytes that form a class.
+   * @param domain the ProtectionDomain to give to the class, null for the
+   *        default protection domain
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   * @throws NoClassDefFoundError if the supplied name is not the same as
+   *                              the one specified by the byte buffer.
+   * @throws SecurityException if name starts with "java.", or if certificates
+   *         do not match up
+   * @since 1.5
+   */
+  protected final Class<?> defineClass(String name, ByteBuffer buf,
+				       ProtectionDomain domain)
+    throws ClassFormatError
+  {
+    byte[] data = new byte[buf.remaining()];
+    buf.get(data);
+    return defineClass(name, data, 0, data.length, domain);
+  }
+
+  /**
    * Links the class, if that has not already been done. Linking basically
    * resolves all references to other classes made by this class.
    *


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]