changeset 811:8bc83045abc5 jdk8u5-b10

Merge
author asaha
date Mon, 24 Feb 2014 10:04:33 -0800
parents 2699ac6a6ccb 58214b2432e7
children b4beb1d57fe3
files
diffstat 4 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Feb 20 20:06:01 2014 +0100
+++ b/.hgtags	Mon Feb 24 10:04:33 2014 -0800
@@ -243,6 +243,7 @@
 7e7cb9977a3d1244384ffa454a4890764a07b042 jdk8u5-b02
 2abeb654b57f306f73f3f73bdfa05f93bce2a1f3 jdk8u5-b03
 7c650ceee4902249f32bdc066926b77291007859 jdk8u5-b04
+d88b60cdc8f3cfceb8ef19b095769015b441e37f jdk8u11-b00
 d88b60cdc8f3cfceb8ef19b095769015b441e37f jdk8u5-b05
 d6dfad8b7fb524780ebf4f6b62284cf5679f9ba8 jdk8u5-b06
 96ad962a6a88874830e99e0cd11aece89a1bd1f4 jdk8u5-b07
--- a/src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java	Thu Feb 20 20:06:01 2014 +0100
+++ b/src/jdk/internal/dynalink/beans/AccessibleMembersLookup.java	Mon Feb 24 10:04:33 2014 -0800
@@ -211,7 +211,8 @@
         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 @@
                             //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 @@
             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.
--- a/src/jdk/internal/dynalink/beans/FacetIntrospector.java	Thu Feb 20 20:06:01 2014 +0100
+++ b/src/jdk/internal/dynalink/beans/FacetIntrospector.java	Mon Feb 24 10:04:33 2014 -0800
@@ -136,7 +136,13 @@
         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);
             }
         }
--- a/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java	Thu Feb 20 20:06:01 2014 +0100
+++ b/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java	Mon Feb 24 10:04:33 2014 -0800
@@ -39,16 +39,38 @@
  * 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.");
     }