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.
()
| 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 | */ |
no test coverage detected