Call to inherited method that is not part of signature is not detected
wilkinsona opened this issue · 0 comments
wilkinsona commented
Animal Sniffer 1.16 misses a call to an inherited method that is not part of the specified signature. Consider the following example:
package com.example;
public class ExampleClassLoader extends ClassLoader {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
synchronized(getClassLoadingLock(name)) {
return super.loadClass(name);
}
}
}
getClassLoadingLock(String)
was added in Java 7. My expectation is that Animal Sniffer will report an error when checking against the Java 6 signature. The actual behaviour is that no error is reported. Please note that an error is reported if the call to getClassLoadingLock(String)
is explicit about it calling a method on the super class:
package com.example;
public class ExampleClassLoader extends ClassLoader {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
synchronized(super.getClassLoadingLock(name)) {
return super.loadClass(name);
}
}
}
Here's a complete sample that reproduces the problem.