MCPcopy Create free account
hub / github.com/beanshell/beanshell / toClass

Method toClass

src/bsh/Name.java:626–664  ·  view source on GitHub ↗

Check the cache, else use toObject() to try to resolve to a class identifier. @throws ClassNotFoundException on class not found. @throws ClassPathException (type of EvalError) on special case of ambiguous unqualified name after super import.

()

Source from the content-addressed store, hash-verified

624 ambiguous unqualified name after super import.
625 */
626 synchronized public Class toClass()
627 throws ClassNotFoundException, UtilEvalError
628 {
629 if ( asClass != null )
630 return asClass;
631
632 reset();
633
634 // "var" means untyped, return null class
635 if ( evalName.equals("var") )
636 return asClass = null;
637
638 /* Try straightforward class name first */
639 Class clas = namespace.getClass( evalName );
640
641 if ( clas == null )
642 {
643 /*
644 Try toObject() which knows how to work through inner classes
645 and see what we end up with
646 */
647 Object obj = null;
648 try {
649 // Null interpreter and callstack references.
650 // class only resolution should not require them.
651 obj = toObject( null, null, true );
652 } catch ( UtilEvalError e ) { }; // couldn't resolve it
653
654 if ( obj instanceof ClassIdentifier )
655 clas = ((ClassIdentifier)obj).getTargetClass();
656 }
657
658 if ( clas == null )
659 throw new ClassNotFoundException(
660 "Class: " + value+ " not found in namespace");
661
662 asClass = clas;
663 return asClass;
664 }
665
666 /*
667 */

Callers 6

evalMethod · 0.45
getTypeDescriptorMethod · 0.45
getTypeMethod · 0.45
getImportedClassImplMethod · 0.45
evalNodesMethod · 0.45
objectArrayAllocationMethod · 0.45

Calls 5

resetMethod · 0.95
toObjectMethod · 0.95
getClassMethod · 0.80
getTargetClassMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected