Implementation of getClass() Load a class through this namespace taking into account imports. Check the cache first. If an unqualified name look for imported class or package. Else try to load absolute name. This method implements caching of unqualified names (normally imp
( String name )
| 1073 | @return null if not found. |
| 1074 | */ |
| 1075 | private Class getClassImpl( String name ) |
| 1076 | throws UtilEvalError |
| 1077 | { |
| 1078 | Class c = null; |
| 1079 | |
| 1080 | // Check the cache |
| 1081 | if (classCache != null) { |
| 1082 | c = classCache.get(name); |
| 1083 | |
| 1084 | if ( c != null ) |
| 1085 | return c; |
| 1086 | } |
| 1087 | |
| 1088 | // Unqualified (simple, non-compound) name |
| 1089 | boolean unqualifiedName = !Name.isCompound(name); |
| 1090 | |
| 1091 | // Unqualified name check imported |
| 1092 | if ( unqualifiedName ) |
| 1093 | { |
| 1094 | // Try imported class |
| 1095 | if ( c == null ) |
| 1096 | c = getImportedClassImpl( name ); |
| 1097 | |
| 1098 | // if found as imported also cache it |
| 1099 | if ( c != null ) { |
| 1100 | cacheClass( name, c ); |
| 1101 | return c; |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | // Try absolute |
| 1106 | c = classForName( name ); |
| 1107 | if ( c != null ) { |
| 1108 | // Cache unqualified names to prevent import check again |
| 1109 | if ( unqualifiedName ) |
| 1110 | cacheClass( name, c ); |
| 1111 | return c; |
| 1112 | } |
| 1113 | |
| 1114 | // Not found |
| 1115 | if ( Interpreter.DEBUG ) |
| 1116 | Interpreter.debug("getClass(): " + name + " not found in "+this); |
| 1117 | return null; |
| 1118 | } |
| 1119 | |
| 1120 | /** |
| 1121 | Try to make the name into an imported class. |
no test coverage detected