public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: URLClassLoader fix
@ 2005-09-15 20:16 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2005-09-15 20:16 UTC (permalink / raw)
  To: Java Patch List

I forget if I posted this here yet.

This fixes part, but not all, of PR 23288.  I've already put it in
Classpath.  (We currently diverge in URLClassLoader...)

Tom

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

	For PR libgcj/23288:
	* java/net/URLClassLoader.java (definePackage): Correctly order
	arguments to definePackage.  Look up per-entry Attributes.
	(getAttributeValue): New method.

Index: java/net/URLClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLClassLoader.java,v
retrieving revision 1.32
diff -u -r1.32 URLClassLoader.java
--- java/net/URLClassLoader.java 9 Sep 2005 13:06:24 -0000 1.32
+++ java/net/URLClassLoader.java 15 Sep 2005 20:14:16 -0000
@@ -941,9 +941,24 @@
   }
 
   /**
+   * Look in both Attributes for a given value.  The first Attributes
+   * object, if not null, has precedence.
+   */
+  private String getAttributeValue(Attributes.Name name, Attributes first,
+				   Attributes second)
+  {
+    String result = null;
+    if (first != null)
+      result = first.getValue(name);
+    if (result == null)
+      result = second.getValue(name);
+    return result;
+  }
+
+  /**
    * Defines a Package based on the given name and the supplied manifest
-   * information. The manifest indicates the tile, version and
-   * vendor information of the specification and implementation and wheter the
+   * information. The manifest indicates the title, version and
+   * vendor information of the specification and implementation and whether the
    * package is sealed. If the Manifest indicates that the package is sealed
    * then the Package will be sealed with respect to the supplied URL.
    *
@@ -958,13 +973,36 @@
   protected Package definePackage(String name, Manifest manifest, URL url)
     throws IllegalArgumentException
   {
+    // Compute the name of the package as it may appear in the
+    // Manifest.
+    StringBuffer xform = new StringBuffer(name);
+    for (int i = xform.length () - 1; i >= 0; --i)
+      if (xform.charAt(i) == '.')
+	xform.setCharAt(i, '/');
+    xform.append('/');
+    String xformName = xform.toString();
+
+    Attributes entryAttr = manifest.getAttributes(xformName);
     Attributes attr = manifest.getMainAttributes();
-    String specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE);
-    String specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION);
-    String specVendor = attr.getValue(Attributes.Name.SPECIFICATION_VENDOR);
-    String implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
-    String implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
-    String implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
+
+    String specTitle
+      = getAttributeValue(Attributes.Name.SPECIFICATION_TITLE,
+			  entryAttr, attr);
+    String specVersion
+      = getAttributeValue(Attributes.Name.SPECIFICATION_VERSION,
+			  entryAttr, attr);
+    String specVendor
+      = getAttributeValue(Attributes.Name.SPECIFICATION_VENDOR,
+			  entryAttr, attr);
+    String implTitle
+      = getAttributeValue(Attributes.Name.IMPLEMENTATION_TITLE,
+			  entryAttr, attr);
+    String implVersion
+      = getAttributeValue(Attributes.Name.IMPLEMENTATION_VERSION,
+			  entryAttr, attr);
+    String implVendor
+      = getAttributeValue(Attributes.Name.IMPLEMENTATION_VENDOR,
+			  entryAttr, attr);
 
     // Look if the Manifest indicates that this package is sealed
     // XXX - most likely not completely correct!
@@ -976,8 +1014,10 @@
       // make sure that the URL is null so the package is not sealed
       url = null;
 
-    return definePackage(name, specTitle, specVersion, specVendor, implTitle,
-                         implVersion, implVendor, url);
+    return definePackage(name,
+			 specTitle, specVendor, specVersion,
+			 implTitle, implVendor, implVersion,
+			 url);
   }
 
   /**

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-15 20:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-15 20:16 Patch: FYI: URLClassLoader fix Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).