aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorBryce McKinlay <mckinlay@redhat.com>2004-07-23 22:20:14 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2004-07-23 23:20:14 +0100
commitec5c28ece1abe76452e1c70918fb44c543b71a81 (patch)
tree96dc496d784f2249834ceb7610963655c445967c /libjava/java
parentae066484dfc4edafddbcf5089720d8ceef28c232 (diff)
downloadgcc-ec5c28ece1abe76452e1c70918fb44c543b71a81.zip
gcc-ec5c28ece1abe76452e1c70918fb44c543b71a81.tar.gz
gcc-ec5c28ece1abe76452e1c70918fb44c543b71a81.tar.bz2
Connection.java: Use GetPropertyAction for privileged getProperty calls.
2004-07-23 Bryce McKinlay <mckinlay@redhat.com> * gnu/java/net/protocol/http/Connection.java: Use GetPropertyAction for privileged getProperty calls. * java/io/ObjectOutputStream.java (getField): No longer static. Use SetAccessibleAction instead of anonymous class for doPrivileged call. (getMethod): Likewise. (setAccessible): New field. PrivilegedAction object to use when calling setAccessible. * java/io/ObjectStreamClass.java (calculateOffsets): Use SetAccessibleAction instead of anonymous class for diPrivileged call. (setFields): Likewise. (getClassUID): Likewise. (findMethod): Likewise. * gnu/java/security/action/GetPropertyAction.java: New class. * gnu/java/security/action/SetAccessibleAction.java: New class. From-SVN: r85097
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/io/ObjectOutputStream.java26
-rw-r--r--libjava/java/io/ObjectStreamClass.java47
2 files changed, 21 insertions, 52 deletions
diff --git a/libjava/java/io/ObjectOutputStream.java b/libjava/java/io/ObjectOutputStream.java
index cc77976..2435b07 100644
--- a/libjava/java/io/ObjectOutputStream.java
+++ b/libjava/java/io/ObjectOutputStream.java
@@ -48,6 +48,7 @@ import java.util.Hashtable;
import gnu.java.io.ObjectIdentityWrapper;
import gnu.java.lang.reflect.TypeSignature;
+import gnu.java.security.action.SetAccessibleAction;
import gnu.classpath.Configuration;
/**
@@ -1516,20 +1517,14 @@ public class ObjectOutputStream extends OutputStream
}
}
- private static Field getField (Class klass, String name)
+ private Field getField (Class klass, String name)
throws java.io.InvalidClassException
{
try
{
final Field f = klass.getDeclaredField(name);
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- f.setAccessible(true);
- return null;
- }
- });
+ setAccessible.setMember(f);
+ AccessController.doPrivileged(setAccessible);
return f;
}
catch (java.lang.NoSuchFieldException e)
@@ -1539,18 +1534,12 @@ public class ObjectOutputStream extends OutputStream
}
}
- private static Method getMethod (Class klass, String name, Class[] args)
+ private Method getMethod (Class klass, String name, Class[] args)
throws java.lang.NoSuchMethodException
{
final Method m = klass.getDeclaredMethod(name, args);
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- m.setAccessible(true);
- return null;
- }
- });
+ setAccessible.setMember(m);
+ AccessController.doPrivileged(setAccessible);
return m;
}
@@ -1583,6 +1572,7 @@ public class ObjectOutputStream extends OutputStream
private Hashtable OIDLookupTable;
private int protocolVersion;
private boolean useSubclassMethod;
+ private SetAccessibleAction setAccessible = new SetAccessibleAction();
// The nesting depth for debugging output
private int depth = 0;
diff --git a/libjava/java/io/ObjectStreamClass.java b/libjava/java/io/ObjectStreamClass.java
index ee23f59..08576cd 100644
--- a/libjava/java/io/ObjectStreamClass.java
+++ b/libjava/java/io/ObjectStreamClass.java
@@ -57,6 +57,7 @@ import java.util.Hashtable;
import java.util.Vector;
import gnu.java.io.NullOutputStream;
import gnu.java.lang.reflect.TypeSignature;
+import gnu.java.security.action.SetAccessibleAction;
import gnu.java.security.provider.Gnu;
@@ -470,14 +471,8 @@ outer:
}
}
final Method m = methods[i];
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- m.setAccessible(true);
- return null;
- }
- });
+ SetAccessibleAction setAccessible = new SetAccessibleAction(m);
+ AccessController.doPrivileged(setAccessible);
return m;
}
}
@@ -543,6 +538,8 @@ outer:
// clazz.
private void setFields(Class cl)
{
+ SetAccessibleAction setAccessible = new SetAccessibleAction();
+
if (!isSerializable() || isExternalizable())
{
fields = NO_FIELDS;
@@ -551,17 +548,11 @@ outer:
try
{
- final Field serialPersistentFields =
+ final Field f =
cl.getDeclaredField("serialPersistentFields");
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- serialPersistentFields.setAccessible(true);
- return null;
- }
- });
- int modifiers = serialPersistentFields.getModifiers();
+ setAccessible.setMember(f);
+ AccessController.doPrivileged(setAccessible);
+ int modifiers = f.getModifiers();
if (Modifier.isStatic(modifiers)
&& Modifier.isFinal(modifiers)
@@ -617,14 +608,8 @@ outer:
if (all_fields[from] != null)
{
final Field f = all_fields[from];
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- f.setAccessible(true);
- return null;
- }
- });
+ setAccessible.setMember(f);
+ AccessController.doPrivileged(setAccessible);
fields[to] = new ObjectStreamField(all_fields[from]);
to++;
}
@@ -651,14 +636,8 @@ outer:
// may not be public AND we only want the serialVersionUID of this
// class, not a superclass or interface.
final Field suid = cl.getDeclaredField("serialVersionUID");
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- suid.setAccessible(true);
- return null;
- }
- });
+ SetAccessibleAction setAccessible = new SetAccessibleAction(suid);
+ AccessController.doPrivileged(setAccessible);
int modifiers = suid.getModifiers();
if (Modifier.isStatic(modifiers)