nashorn/src/jdk/nashorn/internal/lookup/Lookup.java
changeset 18855 408663ef8f66
parent 16277 fd698c5ee684
child 18865 8844964e5fc5
equal deleted inserted replaced
18854:8dd3bfd73623 18855:408663ef8f66
   123     public static void typeErrorThrowerSetter(final Object self, final Object value) {
   123     public static void typeErrorThrowerSetter(final Object self, final Object value) {
   124         throw typeError("strict.getter.setter.poison", ScriptRuntime.safeToString(self));
   124         throw typeError("strict.getter.setter.poison", ScriptRuntime.safeToString(self));
   125     }
   125     }
   126 
   126 
   127     /**
   127     /**
   128      * Create a new {@link Property}
       
   129      *
       
   130      * @param map             property map
       
   131      * @param key             property key
       
   132      * @param flags           property flags
       
   133      * @param propertyGetter  getter for property if available, null otherwise
       
   134      * @param propertySetter  setter for property if available, null otherwise
       
   135      *
       
   136      * @return new property map, representing {@code PropertyMap} with the new property added to it
       
   137      */
       
   138     @SuppressWarnings("fallthrough")
       
   139     public static PropertyMap newProperty(final PropertyMap map, final String key, final int flags, final MethodHandle propertyGetter, final MethodHandle propertySetter) {
       
   140         MethodHandle getter = propertyGetter;
       
   141         MethodHandle setter = propertySetter;
       
   142 
       
   143         // TODO: this is temporary code. This code exists to support reflective
       
   144         // field reader/writer handles generated by "unreflect" lookup.
       
   145 
       
   146         switch (getter.type().parameterCount()) {
       
   147         case 0:
       
   148             // A static field reader, so drop the 'self' argument.
       
   149             getter = MH.dropArguments(getter, 0, Object.class);
       
   150             if (setter != null) {
       
   151                 setter = MH.dropArguments(setter, 0, Object.class);
       
   152             }
       
   153         // fall through
       
   154         case 1:
       
   155             // standard getter that accepts 'self'.
       
   156             break;
       
   157         default:
       
   158             // Huh!! something wrong..
       
   159             throw new IllegalArgumentException("getter/setter has wrong arguments");
       
   160         }
       
   161 
       
   162         return map.newProperty(key, flags, -1, getter, setter);
       
   163     }
       
   164 
       
   165     /**
       
   166      * This method filters primitive return types using JavaScript semantics. For example,
   128      * This method filters primitive return types using JavaScript semantics. For example,
   167      * an (int) cast of a double in Java land is not the same thing as invoking toInt32 on it.
   129      * an (int) cast of a double in Java land is not the same thing as invoking toInt32 on it.
   168      * If you are returning values to JavaScript that have to be of a specific type, this is
   130      * If you are returning values to JavaScript that have to be of a specific type, this is
   169      * the correct return value filter to use, as the explicitCastArguments just uses the
   131      * the correct return value filter to use, as the explicitCastArguments just uses the
   170      * Java boxing equivalents
   132      * Java boxing equivalents