aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@frijters.net>2004-09-25 19:46:21 +0000
committerMark Wielaard <mark@gcc.gnu.org>2004-09-25 19:46:21 +0000
commit9b2b6c0f33bd20edfc1356c7038ae1ae20467f89 (patch)
treec33989d23c29c649b86696f01472186017048309 /libjava
parentc1f042f8b2eb63fedf2045bab0a449071993fdbd (diff)
downloadgcc-9b2b6c0f33bd20edfc1356c7038ae1ae20467f89.zip
gcc-9b2b6c0f33bd20edfc1356c7038ae1ae20467f89.tar.gz
gcc-9b2b6c0f33bd20edfc1356c7038ae1ae20467f89.tar.bz2
Proxy.java (getPackage, [...]): Fixed handling of default package.
2004-09-25 Jeroen Frijters <jeroen@frijters.net> * java/lang/reflect/Proxy.java (getPackage, ClassFactory): Fixed handling of default package. (generate): Removed confused comments and code about making Method and Field accessible. From-SVN: r88109
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/java/lang/reflect/Proxy.java32
2 files changed, 17 insertions, 21 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index af24b1d..dd323d3 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-25 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/lang/reflect/Proxy.java (getPackage, ClassFactory): Fixed
+ handling of default package. (generate): Removed confused comments
+ and code about making Method and Field accessible.
+
2004-09-25 Tom Tromey <tromey@redhat.com>
PR java/17500:
diff --git a/libjava/java/lang/reflect/Proxy.java b/libjava/java/lang/reflect/Proxy.java
index 56d7aeb..66373c5 100644
--- a/libjava/java/lang/reflect/Proxy.java
+++ b/libjava/java/lang/reflect/Proxy.java
@@ -722,8 +722,8 @@ public class Proxy implements Serializable
private static final class ProxyData
{
/**
- * The package this class is in. Possibly null, meaning the unnamed
- * package.
+ * The package this class is in *including the trailing dot* or "" for
+ * the unnamed (aka default) package.
*/
String pack;
@@ -769,18 +769,17 @@ 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
+ * Return the name of a package (including the trailing dot)
+ * given the name of a class.
+ * Returns "" 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)
+ private static String getPackage(Class k)
{
String name = k.getName();
int idx = name.lastIndexOf('.');
- if (idx >= 0)
- return name.substring(0, idx);
- return null;
+ return name.substring(0, idx + 1);
}
/**
@@ -961,8 +960,7 @@ public class Proxy implements Serializable
// access_flags
putU2(Modifier.SUPER | Modifier.FINAL | Modifier.PUBLIC);
// this_class
- qualName = ((data.pack == null ? "" : data.pack + '.')
- + "$Proxy" + data.id);
+ qualName = (data.pack + "$Proxy" + data.id);
putU2(classInfo(TypeSignature.getEncodingOfClass(qualName, false)));
// super_class
putU2(classInfo("java/lang/reflect/Proxy"));
@@ -1325,34 +1323,26 @@ public class Proxy implements Serializable
try
{
- // XXX Do we require more native support here?
-
Class vmClassLoader = Class.forName("java.lang.VMClassLoader");
Class[] types = {ClassLoader.class, String.class,
byte[].class, int.class, int.class,
ProtectionDomain.class };
Method m = vmClassLoader.getDeclaredMethod("defineClass", types);
-
- // Bypass the security check of setAccessible(true), since this
- // is trusted code. But note the comment above about the security
- // risk of doing this outside a synchronized block.
+ // We can bypass the security check of setAccessible(true), since
+ // we're in the same package.
m.flag = true;
+
Object[] args = {loader, qualName, bytecode, new Integer(0),
new Integer(bytecode.length),
Object.class.getProtectionDomain() };
Class clazz = (Class) m.invoke(null, args);
- m.flag = false;
// Finally, initialize the m field of the proxy class, before
// returning it.
-
- // No security risk here, since clazz has not been exposed yet,
- // so user code cannot grab the same reflection object.
Field f = clazz.getDeclaredField("m");
f.flag = true;
// we can share the array, because it is not publicized
f.set(null, methods);
- f.flag = false;
return clazz;
}