ZeroTurnaround Support Forum » JRebel Support

Reflection return old type after field type change

(4 posts)

Tags:


  1. qdolan

    Member
    Posts: 4

    I think I have encountered a bug in the reflection support in javarebel 1.1

    If you have a class Test like so:

    public class Test {
    //	public String foo = "foo";
    	public Integer foo = 12345;
    	public Test() { System.out.println(foo); }
    }

    And you reflect it from another class like so:

    public class Proxy {
    	public static void test() throws Exception {
    		System.out.println(new Test().getClass().getField("foo"));
    	}
    }

    Then call if from a Main class like so:

    public class Main {
    	public static void main(String[] args) throws Exception {
    		while(true) { Proxy.test(); Thread.sleep(500); }
    	}
    }

    If, while running, you change the type of 'foo' in Test from Integer to something else, say String the println in the Test constructor will be correct, but the result of getField() will still be the original type of Integer.

    Posted 2 years ago #
  2. ekabanov

    LeadRebel
    Posts: 546

    Thanks, we'll add a test case and fix it for the next release. Same thing will apply to constructors, where changes are not reflected at all at the moment.

    Posted 2 years ago #
  3. ekabanov

    LeadRebel
    Posts: 546

    Turned out this fails even when changing method return type, a test added here: http://zt-oss.googlecode.com/svn/JavaRebelAutoTest/trunk/incSources/testReflSigChanges/. Will be fixed in upcoming release.

    Posted 2 years ago #
  4. ekabanov

    LeadRebel
    Posts: 546

    Should be fixed in 1.1.1, can you confirm?

    Posted 2 years ago #

RSS feed for this topic

Reply

(required)

(required)

(optional)

(required)

Allowed markup: a blockquote code em strong ul ol li.
Put code in between `backticks`.

Olark Livehelp