package com.siyeh.igtest.abstraction.weaken_type; import java.util.HashMap; import java.util.Map; import java.util.ArrayList; import java.io.FileInputStream; import java.io.FileNotFoundException; public class TypeMayBeWeakened { void weakness() { Map map = new HashMap(); Integer key = 34; map.get(key); } public static String hashes(int len) { StringBuilder sb = new StringBuilder(); for(int i=0;i list) { int i = 0; for (String s: list) { if ("some".equals(s)) { i++; } } return i; } class WeakBoolean { private Boolean myBool; WeakBoolean() { myBool = true; } public void inverse() { myBool = !myBool; } public void xor(boolean b) { myBool ^= b; } } void bar() { foo(new WeakBoolean()); } void foo(WeakBoolean b) { System.out.println("b: " + b); } String foo(String s) { return s + 1; } private static void method() throws IllegalArgumentException { try { FileInputStream fis=new FileInputStream("/etc/modules"); } catch(FileNotFoundException fnfex) { IllegalArgumentException iaex=new IllegalArgumentException("Exception Message"); iaex.initCause(fnfex); throw iaex; } } public static void method(String weakened) { acceptsArray(new String[] {weakened}); } public static void acceptsArray(String[] sarray) {} class Test { int x; void foo() { Test f = new Test(); f.x++; } } void listy(ArrayList list) { for (Object o : list) { } } void construct() { final TypeMayBeWeakened var = new TypeMayBeWeakened(); var.new Test(); } class Param2Weak { public void method(T p) {} } public class Weak2Null extends Param2Weak { public void context(String p) { method(p); } } void simpleIf(Boolean condition) { if (condition); } void simpleFor(Boolean condition) { for (;condition;); } void simpleSwitch(Integer value) { switch (value) { } } Integer simpleConditional(Boolean condition, Integer value1, Integer value2) { return condition ? value1 : value2; } private static java.util.concurrent.atomic.AtomicReference nullSafeReference(java.util.concurrent.atomic.AtomicReference ref, V value) { if (ref != null) ref.set(value); return ref; } } class MyClass { public MyClass(java.util.Date date, String[] classNames) {} static MyClass readMyClass(final ObjectInputStream objectInput) { final long time = objectInput.readLong(); final int size = objectInput.readInt(); final String[] classNames = new String[size]; for (int i = 0; i < size; i++) { classNames[i] = objectInput.readUTF(); } return new MyClass(new java.util.Date(time), classNames); } } interface DataInput { long readLong(); int readInt(); String readUTF(); } abstract class ObjectInputStream implements DataInput { public String readUTF() { return null; } } class Test implements Foo2 { void test(Test t) { t.bar(); } public void bar() { } } @Deprecated interface Foo { void bar(); } interface Foo2 extends Foo {}