25
25
26
26
package com .oracle .svm .hosted ;
27
27
28
+ import java .net .URL ;
28
29
import java .security .CodeSource ;
29
30
30
31
final class ProgressReporterUtils {
@@ -53,15 +54,6 @@ static double toPercentage(long part, long total) {
53
54
return part / (double ) total * 100 ;
54
55
}
55
56
56
- private static String truncateName (String name , double maxLineRatio ) {
57
- int length = name .length ();
58
- int maxLength = maxLength (maxLineRatio );
59
- if (length <= maxLength ) {
60
- return name ;
61
- }
62
- return TRUNCATION_PLACEHOLDER + name .substring (length - maxLength + TRUNCATION_PLACEHOLDER .length (), length );
63
- }
64
-
65
57
static String truncateFQN (String fqn , double maxLineRatio ) {
66
58
return truncateFQN (fqn , maxLength (maxLineRatio ));
67
59
}
@@ -70,7 +62,7 @@ static int maxLength(double maxLineRatio) {
70
62
return (int ) Math .floor (ProgressReporter .CHARACTERS_PER_LINE * maxLineRatio );
71
63
}
72
64
73
- private static String truncateFQN (String fqn , int maxLength ) {
65
+ static String truncateFQN (String fqn , int maxLength ) {
74
66
int classNameLength = fqn .length ();
75
67
if (classNameLength <= maxLength ) {
76
68
return fqn ;
@@ -103,8 +95,11 @@ private static String truncateFQN(String fqn, int maxLength) {
103
95
}
104
96
105
97
static String moduleNamePrefix (Module javaModule ) {
106
- String moduleName = javaModule .isNamed () ? javaModule .getName () : "" ;
107
- return truncateFQN (mapToNativeImageRuntime (moduleName ), 0.10 ) + "/" ;
98
+ if (!javaModule .isNamed ()) {
99
+ return "" ;
100
+ }
101
+ String moduleName = javaModule .getName ();
102
+ return truncateFQN (mapToNativeImageRuntime (moduleName ), 0.12 ) + "/" ;
108
103
}
109
104
110
105
private static String mapToNativeImageRuntime (String moduleName ) {
@@ -122,21 +117,21 @@ static BreakDownClassifier of(Class<?> clazz) {
122
117
123
118
private static String sourcePath (Class <?> clazz ) {
124
119
CodeSource codeSource = clazz .getProtectionDomain ().getCodeSource ();
125
- if (codeSource != null && codeSource .getLocation () != null ) {
126
- String path = codeSource .getLocation ().getPath ();
127
- // Use String API to determine basename of path to handle both / and \.
128
- return path .substring (Math .max (path .lastIndexOf ('/' ) + 1 , path .lastIndexOf ('\\' ) + 1 ));
120
+ if (codeSource != null ) {
121
+ URL sourceLocation = codeSource .getLocation ();
122
+ if (sourceLocation != null && !"jrt" .equals (sourceLocation .getProtocol ())) {
123
+ return sourceLocation .getPath ();
124
+ }
129
125
}
130
126
return null ;
131
127
}
132
128
133
129
public String renderToString (int maxLength ) {
134
- String locationSuffix = location == null ? "" : " (" + truncateName (location , 0.10 ) + ")" ;
135
130
String packageName = javaPackage == null ? "null" : javaPackage .getName ();
136
131
String moduleNamePrefix = moduleNamePrefix (javaModule );
137
132
// Give remainder of space to package-part
138
- int maxLengthPackage = maxLength - moduleNamePrefix .length () - locationSuffix . length () ;
139
- return moduleNamePrefix + truncateFQN (packageName , maxLengthPackage ) + locationSuffix ;
133
+ int maxLengthPackage = maxLength - moduleNamePrefix .length ();
134
+ return moduleNamePrefix + truncateFQN (packageName , maxLengthPackage );
140
135
}
141
136
142
137
public String [] elements () {
0 commit comments