Bug 290698

Summary: [inline] inline method refactoring can produce visibility errors for private member accesses
Product: [Eclipse Project] JDT Reporter: Johannes Gebauer <jogeb>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, markus.kell.r, pyvesdev, timo.kinnunen
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Johannes Gebauer CLA 2009-09-28 09:17:53 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Build Identifier: I20090611-1540

If the Method to be inlined accesses private features of the declaring class and is invoked in another class, the inlined code causes visibility errors.

Reproducible: Always

Steps to Reproduce:
1.
Create the following classes:
public class ReferencingType {

	DeclaringType d = new DeclaringType();
	
	public void n() {
		d.m();
	}
}

public class DeclaringType {
	
	private String privateField;
	
	public void m(){
		System.out.println(privateField);
		privateMethod();
	}
	
	private void privateMethod(){
		
	}
}


2.
Perform an inline method refactoring on DeclaringType.m() and inline all invocations.

3.
The resulting code for the ReferencingType class:

public class ReferencingType {
	
	DeclaringType d = new DeclaringType();
	
	public void n() {
		System.out.println(d.privateField);
		d.privateMethod();
	}
}

The following statements contain private field/method accesses that didn't produce an error in the RefactoringStatus but produce compile errors after the transformation.

System.out.println(d.privateField);
d.privateMethod();
Comment 1 Martin Mathew CLA 2014-05-14 23:05:58 EDT
*** Bug 434745 has been marked as a duplicate of this bug. ***
Comment 2 Eclipse Genie CLA 2019-03-17 10:24:17 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Dani Megert CLA 2019-03-22 12:44:42 EDT
Still broken in 4.11.
Comment 4 Eclipse Genie CLA 2021-07-03 09:29:57 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2023-06-25 13:15:45 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.