summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2006-03-27 01:49:13 +0000
committerTom Tromey <tromey@redhat.com>2006-03-27 01:49:13 +0000
commit799c3d8768696f19639ce3a7dd4777fc17d242d3 (patch)
tree04f6f17ced35b0af42768c6816ab4538a9bb4b25 /vm
parentee3a9cfa4b912f2020a23f8c5483d6d901fc2716 (diff)
downloadclasspath-799c3d8768696f19639ce3a7dd4777fc17d242d3.tar.gz
* NEWS: Updated.
* vm/reference/java/lang/reflect/Method.java (METHOD_MODIFIERS): New constant. (getModifiersInternal): Renamed from getModifiers. (getModifiers): New method. (isBridge): Likewise. (isSynthetic): Likewise. (isVarArgs): Likewise. * vm/reference/java/lang/reflect/Field.java (FIELD_MODIFIERS): New constant. (getModifiersInternal): Renamed from getModifiers. (getModifiers): New method. (isSynthetic): Likewise. (isEnumConstant): Likewise. * vm/reference/java/lang/reflect/Constructor.java (getModifiersInternal): Renamed from getModifiers. (getModifiers): New method (CONSTRUCTOR_MODIFIERS): New constant. (isSynthetic): New method. (isVarArgs): Likewise. * java/lang/reflect/Member.java (isSynthetic): New method.
Diffstat (limited to 'vm')
-rw-r--r--vm/reference/java/lang/reflect/Constructor.java36
-rw-r--r--vm/reference/java/lang/reflect/Field.java35
-rw-r--r--vm/reference/java/lang/reflect/Method.java46
3 files changed, 114 insertions, 3 deletions
diff --git a/vm/reference/java/lang/reflect/Constructor.java b/vm/reference/java/lang/reflect/Constructor.java
index 3789fbb9a..4bc585266 100644
--- a/vm/reference/java/lang/reflect/Constructor.java
+++ b/vm/reference/java/lang/reflect/Constructor.java
@@ -81,6 +81,9 @@ extends AccessibleObject implements Member
private Class clazz;
private int slot;
+ private static final int CONSTRUCTOR_MODIFIERS
+ = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
+
/**
* This class is uninstantiable except from native code.
*/
@@ -114,6 +117,13 @@ extends AccessibleObject implements Member
}
/**
+ * Return the raw modifiers for this constructor. In particular
+ * this will include the synthetic and varargs bits.
+ * @return the constructor's modifiers
+ */
+ private native int getModifiersInternal();
+
+ /**
* Gets the modifiers this constructor uses. Use the <code>Modifier</code>
* class to interpret the values. A constructor can only have a subset of the
* following modifiers: public, private, protected.
@@ -121,7 +131,31 @@ extends AccessibleObject implements Member
* @return an integer representing the modifiers to this Member
* @see Modifier
*/
- public native int getModifiers();
+ public int getModifiers()
+ {
+ return getModifiersInternal() & CONSTRUCTOR_MODIFIERS;
+ }
+
+ /**
+ * Return true if this constructor is synthetic, false otherwise.
+ * A synthetic member is one which is created by the compiler,
+ * and which does not appear in the user's source code.
+ * @since 1.5
+ */
+ public boolean isSynthetic()
+ {
+ return (getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+ }
+
+ /**
+ * Return true if this is a varargs constructor, that is if
+ * the constructor takes a variable number of arguments.
+ * @since 1.5
+ */
+ public boolean isVarArgs()
+ {
+ return (getModifiersInternal() & Modifier.VARARGS) != 0;
+ }
/**
* Get the parameter list for this constructor, in declaration order. If the
diff --git a/vm/reference/java/lang/reflect/Field.java b/vm/reference/java/lang/reflect/Field.java
index 5475aa272..874b7da91 100644
--- a/vm/reference/java/lang/reflect/Field.java
+++ b/vm/reference/java/lang/reflect/Field.java
@@ -80,6 +80,11 @@ extends AccessibleObject implements Member
private String name;
private int slot;
+ private static final int FIELD_MODIFIERS
+ = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
+ | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
+ | Modifier.VOLATILE;
+
/**
* This class is uninstantiable except natively.
*/
@@ -110,6 +115,12 @@ extends AccessibleObject implements Member
}
/**
+ * Return the raw modifiers for this field.
+ * @return the field's modifiers
+ */
+ private native int getModifiersInternal();
+
+ /**
* Gets the modifiers this field uses. Use the <code>Modifier</code>
* class to interpret the values. A field can only have a subset of the
* following modifiers: public, private, protected, static, final,
@@ -118,7 +129,29 @@ extends AccessibleObject implements Member
* @return an integer representing the modifiers to this Member
* @see Modifier
*/
- public native int getModifiers();
+ public int getModifiers()
+ {
+ return getModifiersInternal() & FIELD_MODIFIERS;
+ }
+
+ /**
+ * Return true if this field is synthetic, false otherwise.
+ * @since 1.5
+ */
+ public boolean isSynthetic()
+ {
+ return (getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+ }
+
+ /**
+ * Return true if this field represents an enum constant,
+ * false otherwise.
+ * @since 1.5
+ */
+ public boolean isEnumConstant()
+ {
+ return (getModifiersInternal() & Modifier.ENUM) != 0;
+ }
/**
* Gets the type of this field.
diff --git a/vm/reference/java/lang/reflect/Method.java b/vm/reference/java/lang/reflect/Method.java
index 4da8d5c66..7a4def9ae 100644
--- a/vm/reference/java/lang/reflect/Method.java
+++ b/vm/reference/java/lang/reflect/Method.java
@@ -82,6 +82,11 @@ extends AccessibleObject implements Member
String name;
int slot;
+ private static final int METHOD_MODIFIERS
+ = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
+ | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
+ | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
+
/**
* This class is uninstantiable.
*/
@@ -112,6 +117,12 @@ extends AccessibleObject implements Member
}
/**
+ * Return the raw modifiers for this method.
+ * @return the method's modifiers
+ */
+ private native int getModifiersInternal();
+
+ /**
* Gets the modifiers this method uses. Use the <code>Modifier</code>
* class to interpret the values. A method can only have a subset of the
* following modifiers: public, private, protected, abstract, static,
@@ -120,7 +131,40 @@ extends AccessibleObject implements Member
* @return an integer representing the modifiers to this Member
* @see Modifier
*/
- public native int getModifiers();
+ public int getModifiers()
+ {
+ return getModifiersInternal() & METHOD_MODIFIERS;
+ }
+
+ /**
+ * Return true if this method is a bridge method. A bridge method
+ * is generated by the compiler in some situations involving
+ * generics and inheritance.
+ * @since 1.5
+ */
+ public boolean isBridge()
+ {
+ return (getModifiersInternal() & Modifier.BRIDGE) != 0;
+ }
+
+ /**
+ * Return true if this method is synthetic, false otherwise.
+ * @since 1.5
+ */
+ public boolean isSynthetic()
+ {
+ return (getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+ }
+
+ /**
+ * Return true if this is a varargs method, that is if
+ * the method takes a variable number of arguments.
+ * @since 1.5
+ */
+ public boolean isVarArgs()
+ {
+ return (getModifiersInternal() & Modifier.VARARGS) != 0;
+ }
/**
* Gets the return type of this method.