This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 243847 - Object is not null but shown as null
Summary: Object is not null but shown as null
Status: RESOLVED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 8.0
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-15 11:27 UTC by yeuchimse
Modified: 2014-07-28 05:22 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot (52.32 KB, image/jpeg)
2014-04-15 11:27 UTC, yeuchimse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yeuchimse 2014-04-15 11:27:07 UTC
Created attachment 146761 [details]
Screenshot

Hi, i have the following snippet:

public class Test {

    public static class Data {

        public void sayHello() {
            System.err.println("Hello");
        }
    }

    public static class Cha {

        public Data data;

        public void sayHello() {
            this.data.sayHello();
        }
    }

    public static class Con extends Cha {

        public Data data;
    }

    public static void main(String[] args) {
        Cha obj = new Con();
        obj.data = new Data();

        Data data = obj.data;
        data.sayHello();
    }

}

When I stopped at the line: 

Data data = obj.data;

The Variables window showed that the value of obj.data is null. But on the next line, the value of variable data is not null (obj.data is still null). Can I call this a bug?
Comment 1 Martin Entlicher 2014-04-16 06:54:36 UTC
Reproduced. When "obj" is expanded in Variables window, data shows null (from Con class) and Inherited data shows the value that was set (from Cha class).
Debugger seems to be inconsistent with the runtime.

In the runtime ((Cha) obj).data is used, but ((Con) obj).data is displayed in debugger.
Comment 2 Martin Entlicher 2014-07-24 13:07:36 UTC
Fixed by changeset:   276510:4627b96ba353
http://hg.netbeans.org/core-main/rev/4627b96ba353
Comment 3 Quality Engineering 2014-07-28 05:22:20 UTC
Integrated into 'main-silver', will be available in build *201407280405* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4627b96ba353
User: mentlicher@netbeans.org
Log: #243847: When retrieving a value of a field on an object, prefer the object type declared in the source code.