Commit 6077db91 by Tom Tromey Committed by Tom Tromey

Proxy.java (ProxyData): `pack' now a String.

	* java/lang/reflect/Proxy.java (ProxyData): `pack' now a String.
	(ProxyData.getPackage): New method.
	(ProxyData.getProxyData): Use package name, not Package.
	(ClassFactory.ClassFactory): Updated.

From-SVN: r70809
parent e3232933
2003-08-26 Tom Tromey <tromey@redhat.com>
* java/lang/reflect/Proxy.java (ProxyData): `pack' now a String.
(ProxyData.getPackage): New method.
(ProxyData.getProxyData): Use package name, not Package.
(ClassFactory.ClassFactory): Updated.
2003-08-25 Scott Gilbertson <scottg@mantatest.com> 2003-08-25 Scott Gilbertson <scottg@mantatest.com>
* Makefile.am: added gnu/awt/xlib/XOffScreenImage.java. * Makefile.am: added gnu/awt/xlib/XOffScreenImage.java.
* Makefile.in: re-generated. * Makefile.in: re-generated.
......
/* Proxy.java -- build a proxy class that implements reflected interfaces /* Proxy.java -- build a proxy class that implements reflected interfaces
Copyright (C) 2001, 2002 Free Software Foundation, Inc. Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -733,7 +733,7 @@ public class Proxy implements Serializable ...@@ -733,7 +733,7 @@ public class Proxy implements Serializable
* The package this class is in. Possibly null, meaning the unnamed * The package this class is in. Possibly null, meaning the unnamed
* package. * package.
*/ */
Package pack; String pack;
/** /**
* The interfaces this class implements. Non-null, but possibly empty. * The interfaces this class implements. Non-null, but possibly empty.
...@@ -777,6 +777,21 @@ public class Proxy implements Serializable ...@@ -777,6 +777,21 @@ public class Proxy implements Serializable
} }
/** /**
* Return the name of a package given the name of a class.
* Returns null if no package. We use this in preference to
* using Class.getPackage() to avoid problems with ClassLoaders
* that don't set the package.
*/
static String getPackage(Class k)
{
String name = k.getName();
int idx = name.lastIndexOf('.');
if (idx >= 0)
return name.substring(0, idx);
return null;
}
/**
* Verifies that the arguments are legal, and sets up remaining data * Verifies that the arguments are legal, and sets up remaining data
* This should only be called when a class must be generated, as * This should only be called when a class must be generated, as
* it is expensive. * it is expensive.
...@@ -818,8 +833,8 @@ public class Proxy implements Serializable ...@@ -818,8 +833,8 @@ public class Proxy implements Serializable
if (! Modifier.isPublic(inter.getModifiers())) if (! Modifier.isPublic(inter.getModifiers()))
if (in_package) if (in_package)
{ {
Package p = inter.getPackage(); String p = getPackage(inter);
if (data.pack != inter.getPackage()) if (! data.pack.equals(p))
throw new IllegalArgumentException("non-public interfaces " throw new IllegalArgumentException("non-public interfaces "
+ "from different " + "from different "
+ "packages"); + "packages");
...@@ -827,7 +842,7 @@ public class Proxy implements Serializable ...@@ -827,7 +842,7 @@ public class Proxy implements Serializable
else else
{ {
in_package = true; in_package = true;
data.pack = inter.getPackage(); data.pack = getPackage(inter);
} }
for (int j = i-1; j >= 0; j--) for (int j = i-1; j >= 0; j--)
if (data.interfaces[j] == inter) if (data.interfaces[j] == inter)
...@@ -954,7 +969,7 @@ public class Proxy implements Serializable ...@@ -954,7 +969,7 @@ public class Proxy implements Serializable
// access_flags // access_flags
putU2(Modifier.SUPER | Modifier.FINAL | Modifier.PUBLIC); putU2(Modifier.SUPER | Modifier.FINAL | Modifier.PUBLIC);
// this_class // this_class
qualName = ((data.pack == null ? "" : data.pack.getName() + '.') qualName = ((data.pack == null ? "" : data.pack + '.')
+ "$Proxy" + data.id); + "$Proxy" + data.id);
putU2(classInfo(TypeSignature.getEncodingOfClass(qualName, false))); putU2(classInfo(TypeSignature.getEncodingOfClass(qualName, false)));
// super_class // super_class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment