Some changes to testinputs to make them compilable (all I want/can do
for this :) Also fixed NPE in usage checks (bug 1165855)
This commit is contained in:
parent
458086242f
commit
0595eb9096
|
|
@ -182,7 +182,7 @@
|
|||
<!-- start of a change to turn on compilation of all input files -->
|
||||
<!-- under JDK1.5. -->
|
||||
<property name="testExcludes"
|
||||
value="**/grammars/*,**/j2ee/*,**/InputAssertIdentifier.java,**/InputSimple.java,**/InputTags.java,**/InputJUnitTest.java,**/InputValidMethodIndent.java,**/InputSetterGetter.java,**/InputImport.java,**/InputUnusedMethod.java"/>
|
||||
value="**/grammars/*,**/j2ee/*,**/InputAssertIdentifier.java,**/InputJUnitTest.java,**/InputValidMethodIndent.java,**/InputSetterGetter.java,**/InputImport.java,**/InputCovariant.java,**/InputClone.java,**/InputSimple.java"/>
|
||||
<javac srcdir="src/testinputs"
|
||||
destdir="target/testinputs"
|
||||
deprecation="on" debug="on"
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ public abstract class AbstractUsageCheck
|
|||
/** @see com.puppycrawl.tools.checkstyle.api.Check */
|
||||
public void finishTree(DetailAST aAST)
|
||||
{
|
||||
if (aAST == null) {
|
||||
// we have nothing to check
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Set nodes = getASTManager().getCheckNodes(this);
|
||||
if (nodes != null) {
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ class InputTags1
|
|||
|
||||
/** {@inheritDoc} */
|
||||
int method26()
|
||||
{
|
||||
{ return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -277,7 +277,7 @@ class InputTags1
|
|||
* @return something very important.
|
||||
*/
|
||||
int method27(int aParam)
|
||||
{
|
||||
{ return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -285,7 +285,7 @@ class InputTags1
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
int method28(int aParam)
|
||||
{
|
||||
{ return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -359,3 +359,10 @@ public class InputTags {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Added to make this file compilable.
|
||||
*/
|
||||
class WrongException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class CloneWithTypeArguments
|
|||
{
|
||||
public <T> Object clone()
|
||||
{
|
||||
super.<T>clone();
|
||||
return super.<T>clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,4 +70,4 @@ class MyClassWithGenericSuperMethod
|
|||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,11 +60,14 @@ enum InputExplicitInit3 {
|
|||
}
|
||||
|
||||
class ForEach {
|
||||
public ForEach(Collection<String> strings)
|
||||
public ForEach(java.util.Collection<String> strings)
|
||||
{
|
||||
for(String s : strings) //this should not even be checked
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Bar<T> {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ class InnerFinalize
|
|||
}
|
||||
|
||||
//Check that super keword isn't snagged here
|
||||
class MyClassWithGenericSuperMethod
|
||||
class MyClassWithGenericSuperMethod1
|
||||
{
|
||||
void someMethod(java.util.List<? super java.util.Map> l)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
// this is an empty file
|
||||
// it's a test for 1165855
|
||||
|
|
@ -86,7 +86,7 @@ class SerializableTest implements java.io.Serializable
|
|||
}
|
||||
}
|
||||
|
||||
class BadSerializableTest implements java.io.Serializable
|
||||
class BadSerializableTest1 implements java.io.Serializable
|
||||
{
|
||||
private void writeObject(Object out) throws java.io.IOException
|
||||
{
|
||||
|
|
@ -100,36 +100,19 @@ class BadSerializableTest implements java.io.Serializable
|
|||
{
|
||||
}
|
||||
|
||||
private int writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
|
||||
{
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException
|
||||
{
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws ClassNotFoundException
|
||||
{
|
||||
}
|
||||
|
||||
private void readObject(Object in) throws java.io.IOException, ClassNotFoundException
|
||||
{
|
||||
}
|
||||
|
||||
private int readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
|
||||
{
|
||||
}
|
||||
|
||||
private int writeReplace() throws java.io.ObjectStreamException
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
private java.lang.Object writeReplace()
|
||||
{
|
||||
return new SerializableTest();
|
||||
}
|
||||
|
||||
private Object writeReplace(int i) throws java.io.ObjectStreamException
|
||||
{
|
||||
return new SerializableTest();
|
||||
|
|
@ -140,13 +123,33 @@ class BadSerializableTest implements java.io.Serializable
|
|||
return 1;
|
||||
}
|
||||
|
||||
private Object readResolve()
|
||||
{
|
||||
return new SerializableTest();
|
||||
}
|
||||
|
||||
private Object readResolve(int i) throws java.io.ObjectStreamException
|
||||
{
|
||||
return new SerializableTest();
|
||||
}
|
||||
}
|
||||
|
||||
class BadSerializableTest2 implements java.io.Serializable
|
||||
{
|
||||
private int writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws ClassNotFoundException
|
||||
{
|
||||
}
|
||||
|
||||
private Object readResolve()
|
||||
{
|
||||
return new SerializableTest();
|
||||
}
|
||||
}
|
||||
|
||||
class BadSerializableTest3 implements java.io.Serializable
|
||||
{
|
||||
private int readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,16 @@ public class UnusedPrivateMethodCheckTest
|
|||
"91:18: Unused private method 'writeObject'.",
|
||||
"95:18: Unused private method 'writeObject'.",
|
||||
"99:18: Unused private method 'writeObject'.",
|
||||
"103:17: Unused private method 'writeObject'.",
|
||||
"103:18: Unused private method 'readObject'.",
|
||||
"107:18: Unused private method 'readObject'.",
|
||||
"111:18: Unused private method 'readObject'.",
|
||||
"115:18: Unused private method 'readObject'.",
|
||||
"119:17: Unused private method 'readObject'.",
|
||||
"123:17: Unused private method 'writeReplace'.",
|
||||
"128:30: Unused private method 'writeReplace'.",
|
||||
"133:20: Unused private method 'writeReplace'.",
|
||||
"138:17: Unused private method 'readResolve'.",
|
||||
"111:17: Unused private method 'writeReplace'.",
|
||||
"116:20: Unused private method 'writeReplace'.",
|
||||
"121:17: Unused private method 'readResolve'.",
|
||||
"126:20: Unused private method 'readResolve'.",
|
||||
"134:17: Unused private method 'writeObject'.",
|
||||
"139:18: Unused private method 'readObject'.",
|
||||
"143:20: Unused private method 'readResolve'.",
|
||||
"148:20: Unused private method 'readResolve'.",
|
||||
"151:17: Unused private method 'readObject'.",
|
||||
};
|
||||
verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected);
|
||||
}
|
||||
|
|
@ -45,17 +44,16 @@ public class UnusedPrivateMethodCheckTest
|
|||
"91:18: Unused private method 'writeObject'.",
|
||||
"95:18: Unused private method 'writeObject'.",
|
||||
"99:18: Unused private method 'writeObject'.",
|
||||
"103:17: Unused private method 'writeObject'.",
|
||||
"103:18: Unused private method 'readObject'.",
|
||||
"107:18: Unused private method 'readObject'.",
|
||||
"111:18: Unused private method 'readObject'.",
|
||||
"115:18: Unused private method 'readObject'.",
|
||||
"119:17: Unused private method 'readObject'.",
|
||||
"123:17: Unused private method 'writeReplace'.",
|
||||
"128:30: Unused private method 'writeReplace'.",
|
||||
"133:20: Unused private method 'writeReplace'.",
|
||||
"138:17: Unused private method 'readResolve'.",
|
||||
"111:17: Unused private method 'writeReplace'.",
|
||||
"116:20: Unused private method 'writeReplace'.",
|
||||
"121:17: Unused private method 'readResolve'.",
|
||||
"126:20: Unused private method 'readResolve'.",
|
||||
"134:17: Unused private method 'writeObject'.",
|
||||
"139:18: Unused private method 'readObject'.",
|
||||
"143:20: Unused private method 'readResolve'.",
|
||||
"148:20: Unused private method 'readResolve'.",
|
||||
"151:17: Unused private method 'readObject'.",
|
||||
};
|
||||
verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected);
|
||||
}
|
||||
|
|
@ -68,4 +66,13 @@ public class UnusedPrivateMethodCheckTest
|
|||
};
|
||||
verify(checkConfig, getPath("usage/InputInnerUsedMethod.java"), expected);
|
||||
}
|
||||
|
||||
public void testEmptyFile() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(UnusedPrivateMethodCheck.class);
|
||||
final String[] expected = {
|
||||
};
|
||||
verify(checkConfig, getPath("usage/InputEmptyFile.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
<li>Fixed bug #1185722 (DeclarationCollector.leaveToken unbalanced
|
||||
with visitToken)</li>
|
||||
|
||||
<li>Fixed NPE in AbstractUsageCheck when we process an empty
|
||||
file (bug 1165855)</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
|
|
|||
Loading…
Reference in New Issue