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]

Patch: FYI: more trampoline removal


I'm checking this in to Classpath and libgcj.

This removes some more trampolines.
It also removes some strange code in CoderResult that I think is
useless.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* java/net/URLClassLoader.java (URLClassLoader): Now
	package-private.
	* java/nio/charset/CoderResult.java (CoderResult): Now
	package-private.
	(get): Likewise.
	(Cache): Likewise.  Don't synchronize on `this'.
	* java/rmi/server/RMIClassLoader.java (MyClassLoader): Now
	package-private.
	* java/util/TimeZone.java (timezones): Now package-private.

Index: java/net/URLClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLClassLoader.java,v
retrieving revision 1.22
diff -u -r1.22 URLClassLoader.java
--- java/net/URLClassLoader.java 28 Sep 2004 09:08:56 -0000 1.22
+++ java/net/URLClassLoader.java 6 Nov 2004 23:22:07 -0000
@@ -1,5 +1,5 @@
 /* URLClassLoader.java --  ClassLoader that loads classes from one or more URLs
-   Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -573,8 +573,9 @@
     addURLs(urls);
   }
 
+  // Package-private to avoid a trampoline constructor.
   /**
-   * Private constructor used by the static
+   * Package-private constructor used by the static
    * <code>newInstance(URL[])</code> method.  Creates an
    * <code>URLClassLoader</code> with the given parent but without any
    * <code>URL</code>s yet. This is used to bypass the normal security
@@ -586,8 +587,7 @@
    *
    * @param securityContext the security context of the unprivileged code.
    */
-  private URLClassLoader(ClassLoader parent,
-                         AccessControlContext securityContext)
+  URLClassLoader(ClassLoader parent, AccessControlContext securityContext)
   {
     super(parent);
     this.factory = null;
Index: java/nio/charset/CoderResult.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/charset/CoderResult.java,v
retrieving revision 1.5
diff -u -r1.5 CoderResult.java
--- java/nio/charset/CoderResult.java 18 Nov 2002 21:34:15 -0000 1.5
+++ java/nio/charset/CoderResult.java 6 Nov 2004 23:22:07 -0000
@@ -1,5 +1,5 @@
 /* CoderResult.java -- 
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -82,7 +82,8 @@
   private final int type;
   private final int length;
 
-  private CoderResult (int type, int length)
+  // Package-private to avoid a trampoline constructor.
+  CoderResult (int type, int length)
   {
     this.type = type;
     this.length = length;
@@ -157,19 +158,14 @@
   {
     private final HashMap cache;
 
-    private Cache ()
+    // Package-private to avoid a trampoline constructor.
+    Cache ()
     {
-      // If we didn't synchronize on this, then cache would be initialized
-      // without holding a lock.  Undefined behavior would occur if the
-      // first thread to call get(int) was not the same as the one that
-      // called the constructor.
-      synchronized (this)
-        {
-          cache = new HashMap ();
-        }
+      cache = new HashMap ();
     }
 
-    private synchronized CoderResult get (int length)
+    // Package-private to avoid a trampoline.
+    synchronized CoderResult get (int length)
     {
       if (length <= 0)
         throw new IllegalArgumentException ("Non-positive length");
Index: java/rmi/server/RMIClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/rmi/server/RMIClassLoader.java,v
retrieving revision 1.12
diff -u -r1.12 RMIClassLoader.java
--- java/rmi/server/RMIClassLoader.java 22 Oct 2004 17:15:57 -0000 1.12
+++ java/rmi/server/RMIClassLoader.java 6 Nov 2004 23:22:08 -0000
@@ -57,7 +57,8 @@
 {
   private static class MyClassLoader extends URLClassLoader
   {
-    private MyClassLoader (URL[] urls, ClassLoader parent, String annotation)
+    // Package-private to avoid a trampoline constructor.
+    MyClassLoader (URL[] urls, ClassLoader parent, String annotation)
     {
       super (urls, parent);
       this.annotation = annotation;
Index: java/util/TimeZone.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/TimeZone.java,v
retrieving revision 1.26
diff -u -r1.26 TimeZone.java
--- java/util/TimeZone.java 7 Sep 2004 07:39:19 -0000 1.26
+++ java/util/TimeZone.java 6 Nov 2004 23:22:08 -0000
@@ -134,7 +134,8 @@
   /* initialize this static field lazily to overhead if
    * it is not needed: 
    */
-  private static synchronized HashMap timezones()
+  // Package-private to avoid a trampoline.
+  static synchronized HashMap timezones()
   {
     if (timezones0 == null) 
       {


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