166 assertEquals(v2b, c.resolveMethod(v2a, c)); |
166 assertEquals(v2b, c.resolveMethod(v2a, c)); |
167 assertEquals(v2b, c.resolveMethod(v2b, c)); |
167 assertEquals(v2b, c.resolveMethod(v2b, c)); |
168 |
168 |
169 } |
169 } |
170 |
170 |
|
171 static class ClassType { |
|
172 } |
|
173 |
|
174 interface InterfaceType { |
|
175 } |
|
176 |
|
177 @Test |
|
178 public void testCloneAccessibility() { |
|
179 /* |
|
180 * The resolution machinery for clone on arrays has some hacks in that show up in odd places |
|
181 * so make sure that resolveMethod works as expected. |
|
182 */ |
|
183 ResolvedJavaType interfaceType = getType(InterfaceType.class); |
|
184 ResolvedJavaType classType = getType(ClassType.class); |
|
185 ResolvedJavaType arrayType = getType(double[].class); |
|
186 ResolvedJavaMethod cloneMethod = getMethod(getType(Object.class), "clone"); |
|
187 assertEquals("Can't resolve clone for class", cloneMethod, arrayType.resolveMethod(cloneMethod, classType)); |
|
188 assertEquals("Can't resolve clone for interface", cloneMethod, arrayType.resolveMethod(cloneMethod, interfaceType)); |
|
189 } |
|
190 |
171 static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) { |
191 static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) { |
172 for (ResolvedJavaMethod method : type.getDeclaredMethods()) { |
192 for (ResolvedJavaMethod method : type.getDeclaredMethods()) { |
173 if (method.getName().equals(methodName)) { |
193 if (method.getName().equals(methodName)) { |
174 return method; |
194 return method; |
175 } |
195 } |