41
41
package com .oracle .truffle .api .library ;
42
42
43
43
import java .lang .reflect .Method ;
44
- import java .util .Arrays ;
45
- import java .util .Collections ;
46
44
import java .util .List ;
47
45
import java .util .Objects ;
48
46
47
+ import com .oracle .truffle .api .CompilerDirectives ;
49
48
import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
50
49
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
51
50
71
70
public abstract class Message {
72
71
73
72
private final String simpleName ;
74
- private final String qualifiedName ;
73
+ private String qualifiedName ; // lazy init
75
74
private final int id ;
76
- private final int hash ;
77
75
private final boolean deprecated ;
78
76
private final Class <?> returnType ;
79
77
private final Class <? extends Library > libraryClass ;
80
- private final List <Class <?>> parameterTypes ;
81
78
@ CompilationFinal (dimensions = 1 ) private final Class <?>[] parameterTypesArray ;
82
79
private final int parameterCount ;
83
80
@ CompilationFinal LibraryFactory <Library > library ;
@@ -104,15 +101,13 @@ private Message(Class<? extends Library> libraryClass, int id, String messageNam
104
101
Objects .requireNonNull (messageName );
105
102
Objects .requireNonNull (returnType );
106
103
this .libraryClass = libraryClass ;
107
- this .simpleName = messageName .intern ();
104
+ assert messageName .intern () == messageName : "message name must already be interned" ;
105
+ this .simpleName = messageName ;
108
106
this .returnType = returnType ;
109
107
this .parameterTypesArray = parameterTypes ;
110
- this .parameterTypes = Collections .unmodifiableList (Arrays .asList (parameterTypes ));
111
- this .qualifiedName = (getLibraryName () + "." + simpleName + parameters (parameterTypes )).intern ();
112
108
this .deprecated = deprecated ;
113
109
this .id = id ;
114
110
this .parameterCount = parameterTypes .length ;
115
- this .hash = qualifiedName .hashCode ();
116
111
}
117
112
118
113
private static String parameters (Class <?>... parameterTypes ) {
@@ -150,6 +145,10 @@ public final int getId() {
150
145
* @since 19.0
151
146
*/
152
147
public final String getQualifiedName () {
148
+ if (qualifiedName == null ) {
149
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
150
+ qualifiedName = (getLibraryName () + "." + getSimpleName () + parameters (parameterTypesArray )).intern ();
151
+ }
153
152
return qualifiedName ;
154
153
}
155
154
@@ -208,7 +207,7 @@ public final Class<?> getReceiverType() {
208
207
* @since 19.0
209
208
*/
210
209
public final List <Class <?>> getParameterTypes () {
211
- return parameterTypes ;
210
+ return List . of ( parameterTypesArray ) ;
212
211
}
213
212
214
213
/**
@@ -256,26 +255,6 @@ public final LibraryFactory<?> getFactory() {
256
255
return library ;
257
256
}
258
257
259
- /**
260
- * {@inheritDoc}
261
- *
262
- * @since 19.0
263
- */
264
- @ Override
265
- public final boolean equals (Object obj ) {
266
- return this == obj ;
267
- }
268
-
269
- /**
270
- * {@inheritDoc}
271
- *
272
- * @since 19.0
273
- */
274
- @ Override
275
- public final int hashCode () {
276
- return hash ;
277
- }
278
-
279
258
/**
280
259
* {@inheritDoc}
281
260
*
0 commit comments