@@ -115,21 +115,19 @@ private static boolean isTrustedInterface(Class<?> cls) {
115
115
private boolean isAssignableToRestrictedType (ValueNode node , MetaAccessProvider metaAccess ) {
116
116
if (node .stamp (NodeView .DEFAULT ) instanceof ObjectStamp ) {
117
117
ResolvedJavaType restrictedType = metaAccess .lookupJavaType (restrictedClass );
118
- ResolvedJavaType nodeType = StampTool .typeOrNull (node );
119
- if (nodeType == null && node instanceof LoadFieldNode ) {
120
- nodeType = ( ResolvedJavaType ) (( LoadFieldNode ) node ) .field ().getType ();
118
+ JavaType nodeType = StampTool .typeOrNull (node );
119
+ if (nodeType == null && node instanceof LoadFieldNode load ) {
120
+ nodeType = load .field ().getType ();
121
121
}
122
- if (nodeType == null && node instanceof Invoke ) {
123
- ResolvedJavaMethod target = (( Invoke ) node ) .callTarget ().targetMethod ();
124
- nodeType = ( ResolvedJavaType ) target .getSignature ().getReturnType (target .getDeclaringClass ());
122
+ if (nodeType == null && node instanceof Invoke invoke ) {
123
+ ResolvedJavaMethod target = invoke .callTarget ().targetMethod ();
124
+ nodeType = target .getSignature ().getReturnType (target .getDeclaringClass ());
125
125
}
126
- if (nodeType == null && node instanceof UncheckedInterfaceProvider ) {
127
- nodeType = StampTool .typeOrNull ((( UncheckedInterfaceProvider ) node ) .uncheckedStamp ());
126
+ if (nodeType == null && node instanceof UncheckedInterfaceProvider uip ) {
127
+ nodeType = StampTool .typeOrNull (uip .uncheckedStamp ());
128
128
}
129
129
130
- if (nodeType != null && restrictedType .isAssignableFrom (nodeType )) {
131
- return true ;
132
- }
130
+ return nodeType instanceof ResolvedJavaType resolved && restrictedType .isAssignableFrom (resolved );
133
131
}
134
132
return false ;
135
133
}
@@ -162,9 +160,7 @@ private static boolean isEqualsMethod(ResolvedJavaMethod method) {
162
160
if (sig .getReturnKind () == JavaKind .Boolean ) {
163
161
if (sig .getParameterCount (false ) == 1 ) {
164
162
ResolvedJavaType ptype = (ResolvedJavaType ) sig .getParameterType (0 , method .getDeclaringClass ());
165
- if (ptype .isJavaLangObject ()) {
166
- return true ;
167
- }
163
+ return ptype .isJavaLangObject ();
168
164
169
165
}
170
166
}
@@ -184,10 +180,7 @@ private boolean isIllegalUsage(ResolvedJavaMethod method, ValueNode x, ValueNode
184
180
if ((isAssignableToRestrictedType (x , context .getMetaAccess ()) || isAssignableToRestrictedType (y , context .getMetaAccess ())) &&
185
181
!isSafeConstant (x , context .getConstantReflection (), context .getSnippetReflection ()) &&
186
182
!isSafeConstant (y , context .getConstantReflection (), context .getSnippetReflection ())) {
187
- if (isEqualsMethod (method ) && (isThisParameter (x ) || isThisParameter (y ))) {
188
- return false ;
189
- }
190
- return true ;
183
+ return !isEqualsMethod (method ) || (!isThisParameter (x ) && !isThisParameter (y ));
191
184
}
192
185
return false ;
193
186
}
0 commit comments