diff --git a/jode/test/HintTypeTest.java b/jode/test/HintTypeTest.java new file mode 100644 index 0000000..28ea5fe --- /dev/null +++ b/jode/test/HintTypeTest.java @@ -0,0 +1,32 @@ +package jode.test; + +/** + * The primitive types can give some headaches. You almost never can say + * if a local variable is of type int, char, short etc.

+ * + * Most times this doesn't matter this much, but with int and character's + * this can get ugly.

+ * + * The solution is to give every variable a hint, which type it probably is. + * The hint reset, when the type is not possible. For integer types we try + * to set it to the smallest explicitly assigned type.

+ * + * Some operators will propagate this hint.

+ */ +public class HintTypeTest { + + public void charLocal() { + String s= "Hallo"; + for (int i=0; i< s.length(); i++) { + char c = s.charAt(i); + if (c == 'H') + // The widening to int doesn't occur in byte code, but + // is necessary. This is really difficult. + System.err.println("H is "+(int)c); + else + System.err.println(""+c+" is "+(int)c); + } + } +} + +