< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NativeJavaPackage.java

Print this page




 189      */
 190     @Function(attributes = Attribute.NOT_ENUMERABLE)
 191     public static Object __noSuchMethod__(final Object self, final Object... args) {
 192         throw new AssertionError("__noSuchMethod__ placeholder called");
 193     }
 194 
 195     /**
 196      * Handle creation of new attribute.
 197      * @param desc the call site descriptor
 198      * @param request the link request
 199      * @return Link to be invoked at call site.
 200      */
 201     @Override
 202     public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
 203         final String propertyName = desc.getNameToken(2);
 204         createProperty(propertyName);
 205         return super.lookup(desc, request);
 206     }
 207 
 208     @Override
 209     protected Object invokeNoSuchProperty(final String key, final int programPoint) {
 210         final Object retval = createProperty(key);
 211         if (isValid(programPoint)) {
 212             throw new UnwarrantedOptimismException(retval, programPoint);
 213         }
 214         return retval;
 215     }
 216 
 217     @Override
 218     public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
 219         return noSuchProperty(desc, request);
 220     }
 221 
 222     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
 223         return MH.findStatic(MethodHandles.lookup(), NativeJavaPackage.class, name, MH.type(rtype, types));
 224     }
 225 
 226     private Object createProperty(final String propertyName) {
 227         final String fullName     = name.isEmpty() ? propertyName : name + "." + propertyName;
 228         final Context context = Context.getContextTrusted();
 229 




 189      */
 190     @Function(attributes = Attribute.NOT_ENUMERABLE)
 191     public static Object __noSuchMethod__(final Object self, final Object... args) {
 192         throw new AssertionError("__noSuchMethod__ placeholder called");
 193     }
 194 
 195     /**
 196      * Handle creation of new attribute.
 197      * @param desc the call site descriptor
 198      * @param request the link request
 199      * @return Link to be invoked at call site.
 200      */
 201     @Override
 202     public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
 203         final String propertyName = desc.getNameToken(2);
 204         createProperty(propertyName);
 205         return super.lookup(desc, request);
 206     }
 207 
 208     @Override
 209     protected Object invokeNoSuchProperty(final String key, final boolean isScope, final int programPoint) {
 210         final Object retval = createProperty(key);
 211         if (isValid(programPoint)) {
 212             throw new UnwarrantedOptimismException(retval, programPoint);
 213         }
 214         return retval;
 215     }
 216 
 217     @Override
 218     public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
 219         return noSuchProperty(desc, request);
 220     }
 221 
 222     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
 223         return MH.findStatic(MethodHandles.lookup(), NativeJavaPackage.class, name, MH.type(rtype, types));
 224     }
 225 
 226     private Object createProperty(final String propertyName) {
 227         final String fullName     = name.isEmpty() ? propertyName : name + "." + propertyName;
 228         final Context context = Context.getContextTrusted();
 229 


< prev index next >