Bug 37801 - JDT compiler bug ?
Summary: JDT compiler bug ?
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.0 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-17 08:49 EDT by Haris Peco CLA
Modified: 2003-06-02 06:13 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Haris Peco CLA 2003-05-17 08:49:02 EDT
Hello,
I have a problem with jdt compiler (same behavior is for sun jdk 1.3.1 and jdk
1.4.1).
Refactor -> rename don't work with jdk 1.4.1 (compliance 1.4 in eclipse jdt) and
I think that problem is different behavior for protected method in different
package.
example :
package eclipse.a (two classes)

package eclipse.a;

public class Parent {
  public Parent() {}

  protected void doSmth(Object obj) {
    System.err.println("Parent.doSmth(Object '" + obj + "')");
  }

  protected void doSmth(String str) {
    System.err.println("Parent.doSmth(String '" + str + "')");
    doSmth((Object)str);
  }
}

package eclipse.a;

import eclipse.b.DerivedB;

public class DerivedA extends Parent {
  private final DerivedB derivedB;

  public DerivedA(DerivedB derivedB) {
    super();
    this.derivedB = derivedB;
  }

  protected void doSmth(String str) {
    System.err.println("DerivedA.doSmth(String '" + str + "')");
    derivedB.doSmth((String)str);
  }

  public static void main(String[] args) {
    DerivedB b = new DerivedB();
    DerivedA a = new DerivedA(b);
    a.doSmth("TEST");
  }
}

Package eclipse.b (one class)

package eclipse.b;

import eclipse.a.Parent;

public class DerivedB extends Parent {

  public DerivedB() {
    super();
  }

  protected void doSmth(String str) {
    System.err.println("DerivedB.doSmth(String '" + str + "')");
  }

}

If compile with jdt 1.3 compliance (and jdk 1.3.1) then result is :
java eclipse.a.DerivedA
DerivedA.doSmth(String 'TEST')
DerivedB.doSmth(String 'TEST')
with jdt 1.4 compliance and jdk 1.4.1 result is :
java eclipse.a.DerivedA
DerivedA.doSmth(String 'TEST')
Parent.doSmth(Object 'TEST')

Solution for problem is for class DerivedA :
package eclipse.a;

import eclipse.b.DerivedB;

public class DerivedA extends Parent {
  private final DerivedB derivedB;

  public DerivedA(DerivedB derivedB) {
    super();
    this.derivedB = derivedB;
  }

  protected void doSmth(String str) {
    System.err.println("DerivedA.doSmth(String '" + str + "')");
    ((Parent)derivedB).doSmth((String)str);
  }

  public static void main(String[] args) {
    DerivedB b = new DerivedB();
    DerivedA a = new DerivedA(b);
    a.doSmth("TEST");
  }
}

regards
Haris Peco
Comment 1 Philipe Mulet CLA 2003-05-19 06:34:45 EDT
DerivedB.doSmth(String) isn't visible to DerivedA since it lives in a different 
package, and isn't inside DerivedA hierarchy.

This is the spec'ed behavior.
Comment 2 Philipe Mulet CLA 2003-05-19 06:36:19 EDT
Closing as invalid.