aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasaha <none@none>2014-02-24 10:04:33 -0800
committerasaha <none@none>2014-02-24 10:04:33 -0800
commit4e8b3245f2b046562e8dc45ca944f835cfbc1862 (patch)
tree8f23a25a1851b79710b7d2bce8290b1a97a2e3cc
parent48ecc599225e041cbfeb6d463b60fd94c19e25ec (diff)
parente6eb3ae3fc195518befc85ccb65b2ad2359762f7 (diff)
downloadnashorn-4e8b3245f2b046562e8dc45ca944f835cfbc1862.tar.gz
-rw-r--r--.hgtags1
-rw-r--r--src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java11
-rw-r--r--src/jdk/internal/dynalink/beans/FacetIntrospector.java8
-rw-r--r--src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java22
4 files changed, 38 insertions, 4 deletions
diff --git a/.hgtags b/.hgtags
index f52a9f98..d1ef80a4 100644
--- a/.hgtags
+++ b/.hgtags
@@ -243,6 +243,7 @@ fdfbb745caf0e54775a44e66e39d3025785e0528 jdk8-b127
7e7cb9977a3d1244384ffa454a4890764a07b042 jdk8u5-b02
2abeb654b57f306f73f3f73bdfa05f93bce2a1f3 jdk8u5-b03
7c650ceee4902249f32bdc066926b77291007859 jdk8u5-b04
+d88b60cdc8f3cfceb8ef19b095769015b441e37f jdk8u11-b00
d88b60cdc8f3cfceb8ef19b095769015b441e37f jdk8u5-b05
d6dfad8b7fb524780ebf4f6b62284cf5679f9ba8 jdk8u5-b06
96ad962a6a88874830e99e0cd11aece89a1bd1f4 jdk8u5-b07
diff --git a/src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java b/src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java
index c82e334a..72beadfe 100644
--- a/src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java
+++ b/src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java
@@ -211,7 +211,8 @@ class AccessibleMembersLookup {
if(!CheckRestrictedPackage.isRestrictedClass(clazz)) {
searchSuperTypes = false;
for(Method method: clazz.getMethods()) {
- if(instance != Modifier.isStatic(method.getModifiers())) {
+ final boolean isStatic = Modifier.isStatic(method.getModifiers());
+ if(instance != isStatic) {
final MethodSignature sig = new MethodSignature(method);
if(!methods.containsKey(sig)) {
final Class<?> declaringClass = method.getDeclaringClass();
@@ -228,7 +229,10 @@ class AccessibleMembersLookup {
//generate the said synthetic delegators.
searchSuperTypes = true;
} else {
- methods.put(sig, method);
+ // don't allow inherited static
+ if (!isStatic || clazz == declaringClass) {
+ methods.put(sig, method);
+ }
}
}
}
@@ -245,7 +249,8 @@ class AccessibleMembersLookup {
searchSuperTypes = true;
}
- if(searchSuperTypes) {
+ // don't need to search super types for static methods
+ if(instance && searchSuperTypes) {
// If we reach here, the class is either not public, or it is in a restricted package. Alternatively, it is
// public, but some of its methods claim that their declaring class is non-public. We'll try superclasses
// and implemented interfaces then looking for public ones.
diff --git a/src/jdk/internal/dynalink/beans/FacetIntrospector.java b/src/jdk/internal/dynalink/beans/FacetIntrospector.java
index f8f1db8f..4ac5deaa 100644
--- a/src/jdk/internal/dynalink/beans/FacetIntrospector.java
+++ b/src/jdk/internal/dynalink/beans/FacetIntrospector.java
@@ -136,7 +136,13 @@ abstract class FacetIntrospector {
final Field[] fields = clazz.getFields();
final Collection<Field> cfields = new ArrayList<>(fields.length);
for(Field field: fields) {
- if(instance != Modifier.isStatic(field.getModifiers()) && isAccessible(field)) {
+ final boolean isStatic = Modifier.isStatic(field.getModifiers());
+ if(isStatic && clazz != field.getDeclaringClass()) {
+ // ignore inherited static fields
+ continue;
+ }
+
+ if(instance != isStatic && isAccessible(field)) {
cfields.add(field);
}
}
diff --git a/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java b/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java
index 32f30764..5997ec54 100644
--- a/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java
+++ b/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java
@@ -39,16 +39,38 @@ import jdk.nashorn.internal.runtime.Context;
* Check java reflection permission for java reflective and java.lang.invoke access from scripts
*/
final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{
+ private static final Class<?> STATEMENT_CLASS = getBeanClass("Statement");
+ private static final Class<?> XMLENCODER_CLASS = getBeanClass("XMLEncoder");
+ private static final Class<?> XMLDECODER_CLASS = getBeanClass("XMLDecoder");
+
+ private static Class<?> getBeanClass(final String name) {
+ try {
+ return Class.forName("java.beans." + name);
+ } catch (final ClassNotFoundException cnfe) {
+ // Possible to miss this class in other profiles.
+ return null;
+ }
+ }
+
@Override
public boolean canLinkType(final Class<?> type) {
return isReflectionClass(type);
}
private static boolean isReflectionClass(final Class<?> type) {
+ // Class or ClassLoader subclasses
if (type == Class.class || ClassLoader.class.isAssignableFrom(type)) {
return true;
}
+ // check for bean reflection
+ if ((STATEMENT_CLASS != null && STATEMENT_CLASS.isAssignableFrom(type)) ||
+ (XMLENCODER_CLASS != null && XMLENCODER_CLASS.isAssignableFrom(type)) ||
+ (XMLDECODER_CLASS != null && XMLDECODER_CLASS.isAssignableFrom(type))) {
+ return true;
+ }
+
+ // package name check
final String name = type.getName();
return name.startsWith("java.lang.reflect.") || name.startsWith("java.lang.invoke.");
}