1 package org.apache.commons.javaflow.bytecode.transformation.rewrite;
2
3 import java.util.Properties;
4
5 /**
6 * A regression test case for handling null in the local variables.
7 *
8 * @author Kohsuke Kawaguchi
9 */
10 public class NullVariableMethodFlow implements Runnable {
11
12 public void run() {
13 getLocalAddress(System.getProperties());
14 }
15
16 public static String getLocalAddress(Properties session) {
17 String x = null, y;
18
19 // when javaflow generates the store/load code around this invocation,
20 // x is of the type 'null'. we have to restore the local variable
21 // in the correct type (in particular not java/lang/Object, but "null")
22 // or otherwise VerifyError occurs.
23 y = session.getProperty("a");
24 if (y == null) {
25 x = session.getProperty("b");
26 }
27
28 if (y == null)
29 y = x;
30
31 return y;
32 }
33 }