aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsundar <none@none>2014-02-21 18:30:02 +0530
committersundar <none@none>2014-02-21 18:30:02 +0530
commite6eb3ae3fc195518befc85ccb65b2ad2359762f7 (patch)
tree8f23a25a1851b79710b7d2bce8290b1a97a2e3cc /src
parent95d5697de85e272b6044ac7b7cc61ef3c4191f45 (diff)
downloadnashorn-e6eb3ae3fc195518befc85ccb65b2ad2359762f7.tar.gz
8034962: Dynalink to handle superclasses more carefully
Reviewed-by: ahgross, attila, jlaskey
Diffstat (limited to 'src')
-rw-r--r--src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java11
-rw-r--r--src/jdk/internal/dynalink/beans/FacetIntrospector.java8
2 files changed, 15 insertions, 4 deletions
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);
}
}