Merge
authorohair
Fri, 15 May 2009 13:21:43 -0700
changeset 121297064d73976f
parent 1211 9eeeeee69368
parent 1204 827a93c4d06a
child 1213 fdbc48164a8b
Merge
     1.1 --- a/.hgtags	Fri May 15 13:14:40 2009 -0700
     1.2 +++ b/.hgtags	Fri May 15 13:21:43 2009 -0700
     1.3 @@ -32,3 +32,5 @@
     1.4  522bb5aa17e0c0cff00b1ed7d1b51bc4db2cfef9 jdk7-b55
     1.5  7fd3bc37afe36f8f6165ba679db1229716db822a jdk7-b56
     1.6  d5a1223e961891564de25c39fba6f2442d0fb045 jdk7-b57
     1.7 +9ba256e2e5c161b89e638390f998baa175ec9abe jdk7-b58
     1.8 +2a5a1b269e89f27ebe419ef4cf6e66a3face0df1 jdk7-b59
     2.1 --- a/make/common/Release.gmk	Fri May 15 13:14:40 2009 -0700
     2.2 +++ b/make/common/Release.gmk	Fri May 15 13:21:43 2009 -0700
     2.3 @@ -52,6 +52,9 @@
     2.4                          com.sun.java.swing.plaf.motif    \
     2.5                          com.sun.java.swing.plaf.gtk
     2.6  
     2.7 +# This is a stopgap until 6839872 is fixed.
     2.8 +EXCLUDE_PROPWARN_PKGS += sun.dyn
     2.9 +
    2.10  # 64-bit solaris has a few special cases. We define the variable
    2.11  # SOLARIS64 for use in this Makefile to easily test those cases
    2.12  ifeq ($(PLATFORM), solaris)
     3.1 --- a/make/docs/CORE_PKGS.gmk	Fri May 15 13:14:40 2009 -0700
     3.2 +++ b/make/docs/CORE_PKGS.gmk	Fri May 15 13:21:43 2009 -0700
     3.3 @@ -97,6 +97,7 @@
     3.4    java.awt.print                                 \
     3.5    java.beans                                     \
     3.6    java.beans.beancontext                         \
     3.7 +  java.dyn                                       \
     3.8    java.io                                        \
     3.9    java.lang                                      \
    3.10    java.lang.annotation                           \
     4.1 --- a/src/share/classes/java/awt/GraphicsDevice.java	Fri May 15 13:14:40 2009 -0700
     4.2 +++ b/src/share/classes/java/awt/GraphicsDevice.java	Fri May 15 13:21:43 2009 -0700
     4.3 @@ -282,7 +282,7 @@
     4.4                  w.setOpacity(1.0f);
     4.5              }
     4.6              Color bgColor = w.getBackground();
     4.7 -            if (bgColor.getAlpha() < 255) {
     4.8 +            if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
     4.9                  bgColor = new Color(bgColor.getRed(), bgColor.getGreen(),
    4.10                                      bgColor.getBlue(), 255);
    4.11                  w.setBackground(bgColor);
     5.1 --- a/src/share/classes/java/dyn/CallSite.java	Fri May 15 13:14:40 2009 -0700
     5.2 +++ b/src/share/classes/java/dyn/CallSite.java	Fri May 15 13:21:43 2009 -0700
     5.3 @@ -28,18 +28,28 @@
     5.4  import sun.dyn.util.BytecodeName;
     5.5  
     5.6  /**
     5.7 - * An <code>invokedynamic</code> call site, as reified to the bootstrap method.
     5.8 - * Every instance of a call site corresponds to a distinct instance
     5.9 - * of the <code>invokedynamic</code> instruction.
    5.10 - * Call sites have state, one reference word, called the <code>target</code>,
    5.11 - * and typed as a {@link MethodHandle}.  When this state is null (as it is
    5.12 - * initially) the call site is in the unlinked state.  Otherwise, it is said
    5.13 - * to be linked to its target.
    5.14 + * An {@code invokedynamic} call site, as reified by the
    5.15 + * containing class's bootstrap method.
    5.16 + * Every call site object corresponds to a distinct instance
    5.17 + * of the <code>invokedynamic</code> instruction, and vice versa.
    5.18 + * Every call site has one state variable, called the {@code target}.
    5.19 + * It is typed as a {@link MethodHandle}.  This state is never null, and
    5.20 + * it is the responsibility of the bootstrap method to produce call sites
    5.21 + * which have been pre-linked to an initial target method.
    5.22   * <p>
    5.23 - * When an unlinked call site is executed, a bootstrap routine is called
    5.24 - * to finish the execution of the call site, and optionally to link
    5.25 - * the call site.
    5.26 + * (Note:  The bootstrap method may elect to produce call sites of a
    5.27 + * language-specific subclass of {@code CallSite}.  In such a case,
    5.28 + * the subclass may claim responsibility for initializing its target to
    5.29 + * a non-null value, by overriding {@link #initialTarget}.)
    5.30   * <p>
    5.31 + * An {@code invokedynamic} instruction which has not yet been executed
    5.32 + * is said to be <em>unlinked</em>.  When an unlinked call site is executed,
    5.33 + * the containing class's bootstrap method is called to manufacture a call site,
    5.34 + * for the instruction.  If the bootstrap method does not assign a non-null
    5.35 + * value to the new call site's target variable, the method {@link #initialTarget}
    5.36 + * is called to produce the new call site's first target method.
    5.37 + * <p>
    5.38 + * @see Linkage#registerBootstrapMethod(java.lang.Class, java.dyn.MethodHandle)
    5.39   * @author John Rose, JSR 292 EG
    5.40   */
    5.41  public class CallSite {
    5.42 @@ -52,6 +62,15 @@
    5.43      final String name;
    5.44      final MethodType type;
    5.45  
    5.46 +    /**
    5.47 +     * Make a call site given the parameters from a call to the bootstrap method.
    5.48 +     * The resulting call site is in an unlinked state, which means that before
    5.49 +     * it is returned from a bootstrap method call it must be provided with
    5.50 +     * a target method via a call to {@link CallSite#setTarget}.
    5.51 +     * @param caller the class in which the relevant {@code invokedynamic} instruction occurs
    5.52 +     * @param name the name specified by the {@code invokedynamic} instruction
    5.53 +     * @param type the method handle type derived from descriptor of the {@code invokedynamic} instruction
    5.54 +     */
    5.55      public CallSite(Object caller, String name, MethodType type) {
    5.56          this.caller = caller;
    5.57          this.name = name;
    5.58 @@ -73,7 +92,9 @@
    5.59       * <p>
    5.60       * If the bootstrap method itself does not initialize the call site,
    5.61       * this method must be overridden, because it just raises an
    5.62 -     * {@code InvokeDynamicBootstrapError}.
    5.63 +     * {@code InvokeDynamicBootstrapError}, which in turn causes the
    5.64 +     * linkage of the {@code invokedynamic} instruction to terminate
    5.65 +     * abnormally.
    5.66       */
    5.67      protected MethodHandle initialTarget() {
    5.68          throw new InvokeDynamicBootstrapError("target must be initialized before call site is linked: "+this);
    5.69 @@ -81,7 +102,7 @@
    5.70  
    5.71      /**
    5.72       * Report the current linkage state of the call site.  (This is mutable.)
    5.73 -     * The value is null if and only if the call site is currently unlinked.
    5.74 +     * The value maybe null only if the call site is currently unlinked.
    5.75       * When a linked call site is invoked, the target method is used directly.
    5.76       * When an unlinked call site is invoked, its bootstrap method receives
    5.77       * the call, as if via {@link Linkage#bootstrapInvokeDynamic}.
    5.78 @@ -113,8 +134,9 @@
    5.79       * into the bootstrap method and/or the target methods used
    5.80       * at any given call site.
    5.81       * @param target the new target, or null if it is to be unlinked
    5.82 -     * @throws WrongMethodTypeException if the new target is not null
    5.83 -     *         and has a method type that differs from the call site's {@link #type}
    5.84 +     * @throws NullPointerException if the proposed new target is null
    5.85 +     * @throws WrongMethodTypeException if the proposed new target
    5.86 +     *         has a method type that differs from the call site's {@link #type()}
    5.87       */
    5.88      public void setTarget(MethodHandle target) {
    5.89          checkTarget(target);
    5.90 @@ -122,6 +144,7 @@
    5.91      }
    5.92  
    5.93      protected void checkTarget(MethodHandle target) {
    5.94 +        target.type();  // provoke NPE
    5.95          if (!canSetTarget(target))
    5.96              throw new WrongMethodTypeException(String.valueOf(target));
    5.97      }
    5.98 @@ -132,7 +155,7 @@
    5.99  
   5.100      /**
   5.101       * Report the class containing the call site.
   5.102 -     * This is immutable static context.
   5.103 +     * This is an immutable property of the call site, set from the first argument to the constructor.
   5.104       * @return class containing the call site
   5.105       */
   5.106      public Class<?> callerClass() {
   5.107 @@ -141,7 +164,7 @@
   5.108  
   5.109      /**
   5.110       * Report the method name specified in the {@code invokedynamic} instruction.
   5.111 -     * This is immutable static context.
   5.112 +     * This is an immutable property of the call site, set from the second argument to the constructor.
   5.113       * <p>
   5.114       * Note that the name is a JVM bytecode name, and as such can be any
   5.115       * non-empty string, as long as it does not contain certain "dangerous"
   5.116 @@ -187,7 +210,7 @@
   5.117       * which are derived from its bytecode-level invocation descriptor.
   5.118       * The types are packaged into a {@link MethodType}.
   5.119       * Any linked target of this call site must be exactly this method type.
   5.120 -     * This is immutable static context.
   5.121 +     * This is an immutable property of the call site, set from the third argument to the constructor.
   5.122       * @return method type specified by the call site
   5.123       */
   5.124      public MethodType type() {
     6.1 --- a/src/share/classes/java/dyn/InvokeDynamic.java	Fri May 15 13:14:40 2009 -0700
     6.2 +++ b/src/share/classes/java/dyn/InvokeDynamic.java	Fri May 15 13:21:43 2009 -0700
     6.3 @@ -26,10 +26,25 @@
     6.4  package java.dyn;
     6.5  
     6.6  /**
     6.7 - * Syntactic marker interface to request javac to emit an {@code invokedynamic} instruction.
     6.8 + * Syntactic marker to request javac to emit an {@code invokedynamic} instruction.
     6.9 + * An {@code invokedynamic} instruction is a 5-byte bytecoded instruction
    6.10 + * which begins with an opcode byte of value 186 ({@code 0xBA}),
    6.11 + * and is followed by a two-byte index of a {@code NameAndType} constant
    6.12 + * pool entry, then by two zero bytes.  The constant pool reference gives
    6.13 + * the method name and argument and return types of the call site; there
    6.14 + * is no other information provided at the call site.
    6.15   * <p>
    6.16 - * This type has no particular meaning as a class or interface supertype, and can never be instantiated.
    6.17 + * The {@code invokedynamic} instruction is incomplete without a target method.
    6.18 + * The target method is a property of the reified call site object
    6.19 + * (of type {@link CallSite}) which is in a one-to-one association with each
    6.20 + * corresponding {@code invokedynamic} instruction.  The call site object
    6.21 + * is initially produced by a <em>bootstrap method</em> associated with
    6.22 + * the call site, via the various overloadings of {@link Linkage#registerBootstrapMethod}.
    6.23 + * <p>
    6.24 + * The type {@code InvokeDynamic} has no particular meaning as a
    6.25 + * class or interface supertype, or an object type; it can never be instantiated.
    6.26   * Logically, it denotes a source of all dynamically typed methods.
    6.27 + * It may be viewed as a pure syntactic marker (an importable one) of static calls.
    6.28   * @author John Rose, JSR 292 EG
    6.29   */
    6.30  public final class InvokeDynamic {
     7.1 --- a/src/share/classes/java/dyn/Linkage.java	Fri May 15 13:14:40 2009 -0700
     7.2 +++ b/src/share/classes/java/dyn/Linkage.java	Fri May 15 13:21:43 2009 -0700
     7.3 @@ -37,16 +37,19 @@
     7.4      private Linkage() {}  // do not instantiate
     7.5  
     7.6      /**
     7.7 -     * Register a bootstrap method for use for a given caller class.
     7.8 -     * The method handle must be of a type equivalent to {@link Linkage#makeCallSite}.
     7.9 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.10 +     * Register a <em>bootstrap method</em> to use when linking a given caller class.
    7.11 +     * It must be a method handle of a type equivalent to {@link CallSite#CallSite}.
    7.12 +     * In other words, it must act as a factory method which accepts the arguments
    7.13 +     * to {@code CallSite}'s constructor (a class, a string, and a method type),
    7.14 +     * and returns a {@code CallSite} object (possibly of a subclass of {@code CallSite}).
    7.15       * <p>
    7.16 -     * The operation will fail with an exception if any of the following conditions hold:
    7.17 +     * The registration will fail with an {@code IllegalStateException} if any of the following conditions hold:
    7.18       * <ul>
    7.19       * <li>The caller of this method is in a different package than the {@code callerClass},
    7.20       *     and there is a security manager, and its {@code checkPermission} call throws
    7.21       *     when passed {@link LinkagePermission}("registerBootstrapMethod",callerClass).
    7.22 -     * <li>The given class already has a bootstrap method, either from an embedded
    7.23 -     *     {@code BootstrapInvokeDynamic} classfile attribute, or from a previous
    7.24 +     * <li>The given class already has a bootstrap method from a previous
    7.25       *     call to this method.
    7.26       * <li>The given class is already fully initialized.
    7.27       * <li>The given class is in the process of initialization, in another thread.
    7.28 @@ -75,9 +78,10 @@
    7.29      }
    7.30  
    7.31      /**
    7.32 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.33       * Simplified version of registerBootstrapMethod for self-registration,
    7.34       * to be called from a static initializer.
    7.35 -     * Finds a static method of type (CallSite, Object[]) -> Object in the
    7.36 +     * Finds a static method of the required type in the
    7.37       * given class, and installs it on the caller.
    7.38       * @throws IllegalArgumentException if there is no such method
    7.39       */
    7.40 @@ -92,9 +96,10 @@
    7.41      }
    7.42  
    7.43      /**
    7.44 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.45       * Simplified version of registerBootstrapMethod for self-registration,
    7.46       * to be called from a static initializer.
    7.47 -     * Finds a static method of type (CallSite, Object[]) -> Object in the
    7.48 +     * Finds a static method of the required type in the
    7.49       * caller's class, and installs it on the caller.
    7.50       * @throws IllegalArgumentException if there is no such method
    7.51       */
    7.52 @@ -109,6 +114,7 @@
    7.53      }
    7.54  
    7.55      /**
    7.56 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.57       * Report the bootstrap method registered for a given class.
    7.58       * Returns null if the class has never yet registered a bootstrap method,
    7.59       * or if the class has explicitly registered a null bootstrap method.
    7.60 @@ -125,8 +131,10 @@
    7.61          }
    7.62      }
    7.63  
    7.64 -    /** The type of any bootstrap method is a three-argument method
    7.65 -     * {@code (Class<?>, String, MethodType)} returning a {@code CallSite}.
    7.66 +    /**
    7.67 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.68 +     * The type of any bootstrap method is a three-argument method
    7.69 +     * {@code (Class, String, MethodType)} returning a {@code CallSite}.
    7.70       */
    7.71      public static final MethodType BOOTSTRAP_METHOD_TYPE
    7.72              = MethodType.make(CallSite.class,
    7.73 @@ -140,6 +148,7 @@
    7.74              new WeakHashMap<Class, MethodHandle>();
    7.75  
    7.76      /**
    7.77 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.78       * Invalidate all <code>invokedynamic</code> call sites everywhere.
    7.79       * <p>
    7.80       * When this method returns, every <code>invokedynamic</code> instruction
    7.81 @@ -163,6 +172,7 @@
    7.82      }
    7.83  
    7.84      /**
    7.85 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
    7.86       * Invalidate all <code>invokedynamic</code> call sites associated
    7.87       * with the given class.
    7.88       * (These are exactly those sites which report the given class
     8.1 --- a/src/share/classes/java/dyn/MethodHandles.java	Fri May 15 13:14:40 2009 -0700
     8.2 +++ b/src/share/classes/java/dyn/MethodHandles.java	Fri May 15 13:21:43 2009 -0700
     8.3 @@ -73,6 +73,7 @@
     8.4      }
     8.5  
     8.6      /**
     8.7 +     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
     8.8       * A factory object for creating method handles, when the creation
     8.9       * requires access checking.  Method handles do not perform
    8.10       * access checks when they are called; this is a major difference
    8.11 @@ -108,8 +109,10 @@
    8.12       * access.  In any of these cases, an exception will be
    8.13       * thrown from the attempted lookup.
    8.14       * In general, the conditions under which a method handle may be
    8.15 -     * created for a method M are exactly as restrictive as the conditions
    8.16 -     * under which the lookup class could have compiled a call to M.
    8.17 +     * created for a method {@code M} are exactly as restrictive as the conditions
    8.18 +     * under which the lookup class could have compiled a call to {@code M}.
    8.19 +     * At least some of these error conditions are likely to be
    8.20 +     * represented by checked exceptions in the final version of this API.
    8.21       */
    8.22      public static final
    8.23      class Lookup {
    8.24 @@ -142,27 +145,30 @@
    8.25              this.lookupClass = lookupClass;
    8.26          }
    8.27  
    8.28 +        private static final Class<?> PUBLIC_ONLY = sun.dyn.empty.Empty.class;
    8.29 +
    8.30          /** Version of lookup which is trusted minimally.
    8.31           *  It can only be used to create method handles to
    8.32           *  publicly accessible members.
    8.33           */
    8.34 -        public static final Lookup PUBLIC_LOOKUP = new Lookup(null);
    8.35 +        public static final Lookup PUBLIC_LOOKUP = new Lookup(PUBLIC_ONLY);
    8.36  
    8.37          /** Package-private version of lookup which is trusted. */
    8.38 -        static final Lookup IMPL_LOOKUP = new Lookup(Access.class);
    8.39 +        static final Lookup IMPL_LOOKUP = new Lookup(null);
    8.40          static { MethodHandleImpl.initLookup(IMPL_TOKEN, IMPL_LOOKUP); }
    8.41  
    8.42          private static void checkUnprivilegedlookupClass(Class<?> lookupClass) {
    8.43 -            if (lookupClass == null ||
    8.44 -                lookupClass == Access.class ||
    8.45 -                lookupClass.getName().startsWith("java.dyn."))
    8.46 +            String name = lookupClass.getName();
    8.47 +            if (name.startsWith("java.dyn.") || name.startsWith("sun.dyn."))
    8.48                  throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
    8.49          }
    8.50  
    8.51          @Override
    8.52          public String toString() {
    8.53 +            if (lookupClass == PUBLIC_ONLY)
    8.54 +                return "public";
    8.55              if (lookupClass == null)
    8.56 -                return "public";
    8.57 +                return "privileged";
    8.58              return lookupClass.getName();
    8.59          }
    8.60  
    8.61 @@ -202,6 +208,13 @@
    8.62           * with the receiver type ({@code defc}) prepended.
    8.63           * The method and all its argument types must be accessible to the lookup class.
    8.64           * <p>
    8.65 +         * (<em>BUG NOTE:</em> The type {@code Object} may be prepended instead
    8.66 +         * of the receiver type, if the receiver type is not on the boot class path.
    8.67 +         * This is due to a temporary JVM limitation, in which MethodHandle
    8.68 +         * claims to be unable to access such classes.  To work around this
    8.69 +         * bug, use {@code convertArguments} to normalize the type of the leading
    8.70 +         * argument to a type on the boot class path, such as {@code Object}.)
    8.71 +         * <p>
    8.72           * When called, the handle will treat the first argument as a receiver
    8.73           * and dispatch on the receiver's type to determine which method
    8.74           * implementation to enter.
    8.75 @@ -222,11 +235,11 @@
    8.76  
    8.77          /**
    8.78           * Produce an early-bound method handle for a virtual method,
    8.79 -         * or a handle for a constructor, as if called from an {@code invokespecial}
    8.80 +         * as if called from an {@code invokespecial}
    8.81           * instruction from {@code caller}.
    8.82 -         * The type of the method handle will be that of the method or constructor,
    8.83 +         * The type of the method handle will be that of the method,
    8.84           * with a suitably restricted receiver type (such as {@code caller}) prepended.
    8.85 -         * The method or constructor and all its argument types must be accessible
    8.86 +         * The method and all its argument types must be accessible
    8.87           * to the caller.
    8.88           * <p>
    8.89           * When called, the handle will treat the first argument as a receiver,
    8.90 @@ -250,8 +263,7 @@
    8.91              MemberName method = IMPL_NAMES.resolveOrFail(new MemberName(defc, name, type), false, specialCaller);
    8.92              checkStatic(false, method, lookupClass);
    8.93              if (name.equals("<init>")) {
    8.94 -                if (defc != specialCaller)
    8.95 -                    throw newNoAccessException("constructor must be local to lookup class", method, lookupClass);
    8.96 +                throw newNoAccessException("cannot directly invoke a constructor", method, null);
    8.97              } else if (defc.isInterface() || !defc.isAssignableFrom(specialCaller)) {
    8.98                  throw newNoAccessException("method must be in a superclass of lookup class", method, lookupClass);
    8.99              }
     9.1 --- a/src/share/classes/java/dyn/MethodType.java	Fri May 15 13:14:40 2009 -0700
     9.2 +++ b/src/share/classes/java/dyn/MethodType.java	Fri May 15 13:21:43 2009 -0700
     9.3 @@ -333,7 +333,7 @@
     9.4  
     9.5      /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
     9.6       * Convert all wrapper types to their corresponding primitive types.
     9.7 -     * A return type of {@java.lang.Void} is changed to {@code void}.
     9.8 +     * A return type of {@code java.lang.Void} is changed to {@code void}.
     9.9       * @return a version of the original type with all wrapper types replaced
    9.10       */
    9.11      public MethodType unwrap() {
    10.1 --- a/src/share/classes/sun/dyn/DirectMethodHandle.java	Fri May 15 13:14:40 2009 -0700
    10.2 +++ b/src/share/classes/sun/dyn/DirectMethodHandle.java	Fri May 15 13:21:43 2009 -0700
    10.3 @@ -45,8 +45,6 @@
    10.4          if (!m.isResolved())
    10.5              throw new InternalError();
    10.6  
    10.7 -        // Null check and replace privilege token (as passed to JVM) with null.
    10.8 -        if (lookupClass.equals(Access.class))  lookupClass = null;
    10.9          MethodHandleNatives.init(this, (Object) m, doDispatch, lookupClass);
   10.10      }
   10.11  
    11.1 --- a/src/share/classes/sun/dyn/MemberName.java	Fri May 15 13:14:40 2009 -0700
    11.2 +++ b/src/share/classes/sun/dyn/MemberName.java	Fri May 15 13:21:43 2009 -0700
    11.3 @@ -450,7 +450,7 @@
    11.4              for (;;) {
    11.5                  int bufCount = MethodHandleNatives.getMembers(defc,
    11.6                          matchName, matchSig, matchFlags,
    11.7 -                        MethodHandleNatives.asNativeCaller(lookupClass),
    11.8 +                        lookupClass,
    11.9                          totalCount, buf);
   11.10                  if (bufCount <= buf.length) {
   11.11                      if (bufCount >= 0)
   11.12 @@ -487,14 +487,13 @@
   11.13              return result;
   11.14          }
   11.15          boolean resolveInPlace(MemberName m, boolean searchSupers, Class<?> lookupClass) {
   11.16 -            Class<?> caller = MethodHandleNatives.asNativeCaller(lookupClass);
   11.17 -            MethodHandleNatives.resolve(m, caller);
   11.18 +            MethodHandleNatives.resolve(m, lookupClass);
   11.19              if (m.isResolved())  return true;
   11.20              int matchFlags = m.flags | (searchSupers ? SEARCH_ALL_SUPERS : 0);
   11.21              String matchSig = m.getSignature();
   11.22              MemberName[] buf = { m };
   11.23              int n = MethodHandleNatives.getMembers(m.getDeclaringClass(),
   11.24 -                    m.getName(), matchSig, matchFlags, caller, 0, buf);
   11.25 +                    m.getName(), matchSig, matchFlags, lookupClass, 0, buf);
   11.26              if (n != 1)  return false;
   11.27              return m.isResolved();
   11.28          }
    12.1 --- a/src/share/classes/sun/dyn/MethodHandleImpl.java	Fri May 15 13:14:40 2009 -0700
    12.2 +++ b/src/share/classes/sun/dyn/MethodHandleImpl.java	Fri May 15 13:21:43 2009 -0700
    12.3 @@ -95,7 +95,7 @@
    12.4  
    12.5      public static void initLookup(Access token, Lookup lookup) {
    12.6          Access.check(token);
    12.7 -        if (IMPL_LOOKUP_INIT != null || lookup.lookupClass() != Access.class)
    12.8 +        if (IMPL_LOOKUP_INIT != null || lookup.lookupClass() != null)
    12.9              throw new InternalError();
   12.10          IMPL_LOOKUP_INIT = lookup;
   12.11      }
   12.12 @@ -144,19 +144,28 @@
   12.13              boolean doDispatch, Class<?> lookupClass) {
   12.14          Access.check(token);  // only trusted calls
   12.15          MethodType mtype = method.getMethodType();
   12.16 +        MethodType rtype = mtype;
   12.17          if (method.isStatic()) {
   12.18              doDispatch = false;
   12.19          } else {
   12.20              // adjust the advertised receiver type to be exactly the one requested
   12.21              // (in the case of invokespecial, this will be the calling class)
   12.22 -            mtype = mtype.insertParameterType(0, method.getDeclaringClass());
   12.23 +            Class<?> recvType = method.getDeclaringClass();
   12.24 +            mtype = mtype.insertParameterType(0, recvType);
   12.25              if (method.isConstructor())
   12.26                  doDispatch = true;
   12.27 +            // FIXME: JVM has trouble building MH.invoke sites for
   12.28 +            // classes off the boot class path
   12.29 +            rtype = mtype;
   12.30 +            if (recvType.getClassLoader() != null)
   12.31 +                rtype = rtype.changeParameterType(0, Object.class);
   12.32          }
   12.33          DirectMethodHandle mh = new DirectMethodHandle(mtype, method, doDispatch, lookupClass);
   12.34          if (!mh.isValid())
   12.35              throw newNoAccessException(method, lookupClass);
   12.36 -        return mh;
   12.37 +        MethodHandle rmh = AdapterMethodHandle.makePairwiseConvert(token, rtype, mh);
   12.38 +        if (rmh == null)  throw new InternalError();
   12.39 +        return rmh;
   12.40      }
   12.41  
   12.42      public static
   12.43 @@ -189,6 +198,15 @@
   12.44      MethodHandle bindReceiver(Access token,
   12.45                                MethodHandle target, Object receiver) {
   12.46          Access.check(token);
   12.47 +        if (target instanceof AdapterMethodHandle) {
   12.48 +            Object info = MethodHandleNatives.getTargetInfo(target);
   12.49 +            if (info instanceof DirectMethodHandle) {
   12.50 +                DirectMethodHandle dmh = (DirectMethodHandle) info;
   12.51 +                if (receiver == null ||
   12.52 +                    dmh.type().parameterType(0).isAssignableFrom(receiver.getClass()))
   12.53 +                    target = dmh;
   12.54 +            }
   12.55 +        }
   12.56          if (target instanceof DirectMethodHandle)
   12.57              return new BoundMethodHandle((DirectMethodHandle)target, receiver, 0);
   12.58          return null;   // let caller try something else
    13.1 --- a/src/share/classes/sun/dyn/MethodHandleNatives.java	Fri May 15 13:14:40 2009 -0700
    13.2 +++ b/src/share/classes/sun/dyn/MethodHandleNatives.java	Fri May 15 13:21:43 2009 -0700
    13.3 @@ -47,14 +47,6 @@
    13.4      static native int getMembers(Class<?> defc, String matchName, String matchSig,
    13.5              int matchFlags, Class<?> caller, int skip, MemberName[] results);
    13.6  
    13.7 -    static Class<?> asNativeCaller(Class<?> lookupClass) {
    13.8 -        if (lookupClass == null)  // means "public only, non-privileged"
    13.9 -            return sun.dyn.empty.Empty.class;
   13.10 -        if (lookupClass == Access.class)  // means "internal, privileged"
   13.11 -            return null;    // to the JVM, null means completely privileged
   13.12 -        return lookupClass;
   13.13 -    }
   13.14 -
   13.15      /// MethodHandle support
   13.16  
   13.17      /** Initialize the method handle to adapt the call. */
    14.1 --- a/src/share/classes/sun/dyn/util/VerifyAccess.java	Fri May 15 13:14:40 2009 -0700
    14.2 +++ b/src/share/classes/sun/dyn/util/VerifyAccess.java	Fri May 15 13:21:43 2009 -0700
    14.3 @@ -95,7 +95,7 @@
    14.4      public static boolean isSamePackage(Class<?> class1, Class<?> class2) {
    14.5          if (class1 == class2)
    14.6              return true;
    14.7 -        if (loadersAreRelated(class1.getClassLoader(), class2.getClassLoader()))
    14.8 +        if (!loadersAreRelated(class1.getClassLoader(), class2.getClassLoader()))
    14.9              return false;
   14.10          String name1 = class1.getName(), name2 = class2.getName();
   14.11          int dot = name1.lastIndexOf('.');
   14.12 @@ -159,7 +159,7 @@
   14.13       */
   14.14      public static void checkBootstrapPrivilege(Class requestingClass, Class subjectClass,
   14.15                                                 String permissionName) {
   14.16 -        if (requestingClass == Access.class)  return;
   14.17 +        if (requestingClass == null)          return;
   14.18          if (requestingClass == subjectClass)  return;
   14.19          SecurityManager security = System.getSecurityManager();
   14.20          if (security == null)  return;  // open season
    15.1 --- a/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Fri May 15 13:14:40 2009 -0700
    15.2 +++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Fri May 15 13:21:43 2009 -0700
    15.3 @@ -530,6 +530,7 @@
    15.4                      sType = transparent ? X11SurfaceData.IntBgrX11_BM : X11SurfaceData.IntBgrX11;
    15.5                  }
    15.6              } else {
    15.7 +
    15.8                  throw new sun.java2d.InvalidPipeException("Unsupported bit " +
    15.9                                                            "depth/cm combo: " +
   15.10                                                            cm.getPixelSize()  +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java	Fri May 15 13:21:43 2009 -0700
    16.3 @@ -0,0 +1,83 @@
    16.4 +/*
    16.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + *
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + *
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + *
   16.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   16.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   16.24 + * have any questions.
   16.25 + */
   16.26 +
   16.27 +/*
   16.28 + * @test
   16.29 + * @bug 6837004
   16.30 + * @summary Checks that non-opaque window can be made a fullscreen window
   16.31 + * @author Artem Ananiev
   16.32 + * @run main TranslucentWindow
   16.33 + */
   16.34 +
   16.35 +import java.awt.*;
   16.36 +import java.awt.geom.*;
   16.37 +
   16.38 +import static java.awt.GraphicsDevice.WindowTranslucency.*;
   16.39 +
   16.40 +import sun.awt.SunToolkit;
   16.41 +
   16.42 +public class TranslucentWindow {
   16.43 +    public static void main(String args[]) {
   16.44 +        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   16.45 +        GraphicsDevice gd = ge.getDefaultScreenDevice();
   16.46 +
   16.47 +        Frame f = new Frame("Test frame");
   16.48 +        f.setBounds(100, 100, 320, 240);
   16.49 +
   16.50 +        // First, check it can be made fullscreen window without any effects applied
   16.51 +        gd.setFullScreenWindow(f);
   16.52 +        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
   16.53 +
   16.54 +        gd.setFullScreenWindow(null);
   16.55 +        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
   16.56 +
   16.57 +        // Second, check if it applying any effects doesn't prevent the window
   16.58 +        // from going into the fullscreen mode
   16.59 +        if (gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT)) {
   16.60 +            f.setShape(new Ellipse2D.Float(0, 0, f.getWidth(), f.getHeight()));
   16.61 +        }
   16.62 +        if (gd.isWindowTranslucencySupported(TRANSLUCENT)) {
   16.63 +            f.setOpacity(0.5f);
   16.64 +        }
   16.65 +        if (gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT)) {
   16.66 +            f.setBackground(new Color(0, 0, 0, 128));
   16.67 +        }
   16.68 +        gd.setFullScreenWindow(f);
   16.69 +        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
   16.70 +
   16.71 +        // Third, make sure all the effects are unset when entering the fullscreen mode
   16.72 +        if (f.getShape() != null) {
   16.73 +            throw new RuntimeException("Test FAILED: fullscreen window shape is not null");
   16.74 +        }
   16.75 +        if (Math.abs(f.getOpacity() - 1.0f) > 1e-4) {
   16.76 +            throw new RuntimeException("Test FAILED: fullscreen window opacity is not 1.0f");
   16.77 +        }
   16.78 +        Color bgColor = f.getBackground();
   16.79 +        if ((bgColor != null) && (bgColor.getAlpha() != 255)) {
   16.80 +            throw new RuntimeException("Test FAILED: fullscreen window background color is not opaque");
   16.81 +        }
   16.82 +
   16.83 +        f.dispose();
   16.84 +        System.out.println("Test PASSED");
   16.85 +    }
   16.86 +}