MCPcopy Create free account
hub / github.com/apache/tomcat / importClass

Method importClass

java/jakarta/el/ImportHandler.java:378–392  ·  view source on GitHub ↗

Imports a class so it can be referenced by its simple name in EL expressions. The argument must be a fully qualified class name. If the simple name conflicts with a previously imported class, an exception is thrown. @param name the fully qualified class name to import @throws ELException if the cl

(String name)

Source from the content-addressed store, hash-verified

376 * @throws ELException if the class name is invalid or conflicts with an existing import
377 */
378 public void importClass(String name) throws ELException {
379 int lastPeriodIndex = name.lastIndexOf('.');
380
381 if (lastPeriodIndex < 0) {
382 throw new ELException(Util.message(null, "importHandler.invalidClassName", name));
383 }
384
385 String unqualifiedName = name.substring(lastPeriodIndex + 1);
386 String currentName = classNames.putIfAbsent(unqualifiedName, name);
387
388 if (currentName != null && !currentName.equals(name)) {
389 // Conflict. Same unqualifiedName, different fully qualified names
390 throw new ELException(Util.message(null, "importHandler.ambiguousImport", name, currentName));
391 }
392 }
393
394
395 /**

Callers 6

testImportClass01Method · 0.95
testImportClass02Method · 0.95
testImportClass03Method · 0.95
testImportClass04Method · 0.95
testResolveInnerClassMethod · 0.95
getELContextMethod · 0.95

Calls 3

messageMethod · 0.95
putIfAbsentMethod · 0.80
equalsMethod · 0.65

Tested by 5

testImportClass01Method · 0.76
testImportClass02Method · 0.76
testImportClass03Method · 0.76
testImportClass04Method · 0.76
testResolveInnerClassMethod · 0.76