MCPcopy Index your code
hub / github.com/apache/tomcat / toJavaSourceType

Method toJavaSourceType

java/org/apache/jasper/compiler/JspUtil.java:980–1018  ·  view source on GitHub ↗

Class.getName() return arrays in the form "[[[<et>", where et, the element type can be one of ZBCDFIJS or L<classname>;. It is converted into forms that can be understood by javac. @param type the type to convert @return the equivalent type in Java sources

(String type)

Source from the content-addressed store, hash-verified

978 * @return the equivalent type in Java sources
979 */
980 public static String toJavaSourceType(String type) {
981
982 if (type.charAt(0) != '[') {
983 return type;
984 }
985
986 int dims = 1;
987 String t = null;
988 for (int i = 1; i < type.length(); i++) {
989 if (type.charAt(i) == '[') {
990 dims++;
991 } else {
992 t = switch (type.charAt(i)) {
993 case 'Z' -> "boolean";
994 case 'B' -> "byte";
995 case 'C' -> "char";
996 case 'D' -> "double";
997 case 'F' -> "float";
998 case 'I' -> "int";
999 case 'J' -> "long";
1000 case 'S' -> "short";
1001 case 'L' -> type.substring(i + 1, type.indexOf(';'));
1002 default -> null;
1003 };
1004 break;
1005 }
1006 }
1007
1008 if (t == null) {
1009 // Should never happen
1010 throw new IllegalArgumentException(Localizer.getMessage("jsp.error.unable.getType", type));
1011 }
1012
1013 StringBuilder resultType = new StringBuilder(t);
1014 for (; dims > 0; dims--) {
1015 resultType.append("[]");
1016 }
1017 return resultType.toString();
1018 }
1019}

Callers 2

interpreterCallMethod · 0.95

Calls 6

getMessageMethod · 0.95
charAtMethod · 0.80
lengthMethod · 0.80
toStringMethod · 0.65
indexOfMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected