001: package com.puppycrawl.tools.checkstyle.usage;
002:
003: /** Test input for unread method check */
004: public class InputUnusedMethod {
005:
006: private void methodUnused0() {
007: }
008:
009: private void methodUsed0() {
010: }
011:
012: private void methodUsed1(int aParam) {
013: }
014:
015: private void methodUsed1(double aParam) {
016: }
017:
018: private void methodUsed1(String aParam) {
019: }
020:
021: public static void main(String[] args) {
022: InputUnusedMethod method = new InputUnusedMethod();
023: method.methodUsed0();
024: method.methodUsed1(0 + 4);
025: method.methodUsed1(Math.sqrt(2.0));
026: method.methodUsed1("" + "a");
027: }
028: }
029:
030: interface InterfaceMethod {
031: public void method(int aParam);
032: }
033:
034: abstract class AbstractClassMethod {
035: public abstract void method(int aParam);
036: }
037:
038: /** Test for bug 880954: false positive when parentheses around second term
039: * of ternary operator.
040: */
041: class Ternary {
042: private int m() {
043: return 1;
044: }
045:
046: public void m1() {
047: int i = 0;
048: int j = (i == 0) ? (i) : m();
049: }
050: }
051:
052: class SerializableTest implements java.io.Serializable {
053: private void writeObject(java.io.ObjectOutputStream out)
054: throws java.io.IOException {
055: // it's ok to have this method in serializable class
056: }
057:
058: private void readObject(java.io.ObjectInputStream in)
059: throws java.io.IOException, ClassNotFoundException {
060: // it's ok to have this method in serializable class
061: }
062:
063: private Object writeReplace() throws java.io.ObjectStreamException {
064: // it's ok to have this method in serializable class
065: return new SerializableTest();
066: }
067:
068: private Object readResolve() throws java.io.ObjectStreamException {
069: // it's ok to have this method in serializable class
070: return new SerializableTest();
071: }
072: }
073:
074: class BadSerializableTest1 implements java.io.Serializable {
075: private void writeObject(Object out) throws java.io.IOException {
076: }
077:
078: private void writeObject(java.io.ObjectOutputStream out, int i)
079: throws java.io.IOException {
080: }
081:
082: private void writeObject(java.io.ObjectOutputStream out) {
083: }
084:
085: private void readObject(java.io.ObjectInputStream in)
086: throws java.io.IOException {
087: }
088:
089: private void readObject(Object in) throws java.io.IOException,
090: ClassNotFoundException {
091: }
092:
093: private int writeReplace() throws java.io.ObjectStreamException {
094: return 1;
095: }
096:
097: private Object writeReplace(int i)
098: throws java.io.ObjectStreamException {
099: return new SerializableTest();
100: }
101:
102: private int readResolve() throws java.io.ObjectStreamException {
103: return 1;
104: }
105:
106: private Object readResolve(int i)
107: throws java.io.ObjectStreamException {
108: return new SerializableTest();
109: }
110: }
111:
112: class BadSerializableTest2 implements java.io.Serializable {
113: private int writeObject(java.io.ObjectOutputStream out)
114: throws java.io.IOException {
115: return 1;
116: }
117:
118: private void readObject(java.io.ObjectInputStream in)
119: throws ClassNotFoundException {
120: }
121:
122: private Object readResolve() {
123: return new SerializableTest();
124: }
125: }
126:
127: class BadSerializableTest3 implements java.io.Serializable {
128: private int readObject(java.io.ObjectInputStream in)
129: throws java.io.IOException, ClassNotFoundException {
130: return 1;
131: }
132: }
|