From 01ae20ed625c5a07e1f2ea5597bb39631cc20f0e Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 7 Mar 1999 15:01:06 +0000 Subject: [PATCH] Initial revision git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@335 379699f6-c40d-0410-875b-85095c16579e --- jode/test/HintTypeTest.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 jode/test/HintTypeTest.java 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); + } + } +} + +