src/jdk/nashorn/internal/runtime/NativeJavaPackage.java

Print this page




 181      * @param self self reference
 182      * @param args arguments to method
 183      * @return never returns
 184      */
 185     @Function(attributes = Attribute.NOT_ENUMERABLE)
 186     public static Object __noSuchMethod__(final Object self, final Object... args) {
 187         throw new AssertionError("__noSuchMethod__ placeholder called");
 188     }
 189 
 190     /**
 191      * Handle creation of new attribute.
 192      * @param desc the call site descriptor
 193      * @param request the link request
 194      * @return Link to be invoked at call site.
 195      */
 196     @Override
 197     public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
 198         final String propertyName = desc.getNameToken(2);
 199         final String fullName     = name.isEmpty() ? propertyName : name + "." + propertyName;
 200 
 201         final Context context = getContext();
 202 
 203         Class<?> javaClass = null;
 204         try {
 205             javaClass = context.findClass(fullName);
 206         } catch (final NoClassDefFoundError | ClassNotFoundException e) {
 207             //ignored
 208         }
 209 
 210         if (javaClass == null) {
 211             set(propertyName, new NativeJavaPackage(fullName, getProto()), false);
 212         } else {
 213             set(propertyName, StaticClass.forClass(javaClass), false);
 214         }
 215 
 216         return super.lookup(desc, request);
 217     }
 218 
 219     @Override
 220     public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
 221         return noSuchProperty(desc, request);


 181      * @param self self reference
 182      * @param args arguments to method
 183      * @return never returns
 184      */
 185     @Function(attributes = Attribute.NOT_ENUMERABLE)
 186     public static Object __noSuchMethod__(final Object self, final Object... args) {
 187         throw new AssertionError("__noSuchMethod__ placeholder called");
 188     }
 189 
 190     /**
 191      * Handle creation of new attribute.
 192      * @param desc the call site descriptor
 193      * @param request the link request
 194      * @return Link to be invoked at call site.
 195      */
 196     @Override
 197     public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
 198         final String propertyName = desc.getNameToken(2);
 199         final String fullName     = name.isEmpty() ? propertyName : name + "." + propertyName;
 200 
 201         final Context context = Context.getContextTrusted();
 202 
 203         Class<?> javaClass = null;
 204         try {
 205             javaClass = context.findClass(fullName);
 206         } catch (final NoClassDefFoundError | ClassNotFoundException e) {
 207             //ignored
 208         }
 209 
 210         if (javaClass == null) {
 211             set(propertyName, new NativeJavaPackage(fullName, getProto()), false);
 212         } else {
 213             set(propertyName, StaticClass.forClass(javaClass), false);
 214         }
 215 
 216         return super.lookup(desc, request);
 217     }
 218 
 219     @Override
 220     public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
 221         return noSuchProperty(desc, request);