@@ -153,7 +153,7 @@ private void init(Class<?> clazz) {
153
153
set ("cast" , new FunctionValue (this ::cast ));
154
154
}
155
155
156
- private Value asSubclass (Value ... args ) {
156
+ private Value asSubclass (Value [] args ) {
157
157
Arguments .check (1 , args .length );
158
158
return new ClassValue (clazz .asSubclass ( ((ClassValue )args [0 ]).clazz ));
159
159
}
@@ -208,7 +208,7 @@ public ObjectValue(Object object) {
208
208
209
209
@ Override
210
210
public boolean containsKey (Value key ) {
211
- return getValue ( object . getClass (), object , key . asString () ) != null ;
211
+ return get ( key ) != null ;
212
212
}
213
213
214
214
@ Override
@@ -228,32 +228,32 @@ public String toString() {
228
228
}
229
229
//</editor-fold>
230
230
231
- private Value isNull (Value ... args ) {
231
+ private Value isNull (Value [] args ) {
232
232
Arguments .checkAtLeast (1 , args .length );
233
233
for (Value arg : args ) {
234
234
if (arg .raw () == null ) return NumberValue .ONE ;
235
235
}
236
236
return NumberValue .ZERO ;
237
237
}
238
238
239
- private Value newClass (Value ... args ) {
239
+ private Value newClass (Value [] args ) {
240
240
Arguments .check (1 , args .length );
241
241
242
242
final String className = args [0 ].asString ();
243
243
try {
244
244
return new ClassValue (Class .forName (className ));
245
245
} catch (ClassNotFoundException ce ) {
246
- return NULL ;
246
+ throw new RuntimeException ( "Class " + className + " not found." , ce ) ;
247
247
}
248
248
}
249
249
250
- private Value toObject (Value ... args ) {
250
+ private Value toObject (Value [] args ) {
251
251
Arguments .check (1 , args .length );
252
252
if (args [0 ] == NULL ) return NULL ;
253
253
return new ObjectValue (valueToObject (args [0 ]));
254
254
}
255
255
256
- private Value toValue (Value ... args ) {
256
+ private Value toValue (Value [] args ) {
257
257
Arguments .check (1 , args .length );
258
258
if (args [0 ] instanceof ObjectValue ) {
259
259
return objectToValue ( ((ObjectValue ) args [0 ]).object );
@@ -305,7 +305,8 @@ private static Value findConstructorAndInstantiate(Value[] args, Constructor<?>[
305
305
// skip
306
306
}
307
307
}
308
- return null ;
308
+ throw new RuntimeException ("Constructor for " + args .length + " arguments"
309
+ + " not found or non accessible" );
309
310
}
310
311
311
312
private static Function methodsToFunction (Object object , List <Method > methods ) {
@@ -323,7 +324,9 @@ private static Function methodsToFunction(Object object, List<Method> methods) {
323
324
// skip
324
325
}
325
326
}
326
- return null ;
327
+ final String className = (object == null ? "null" : object .getClass ().getName ());
328
+ throw new RuntimeException ("Method for " + args .length + " arguments"
329
+ + " not found or non accessible in " + className );
327
330
};
328
331
}
329
332
0 commit comments