Skip to content

Commit fa1bd44

Browse files
committed
Do not consider package private references in calculate uses
Currently only private references are ignored, but in OSGi you can not use a package you export (as in this case either the import or the export is discarded via substitution) making package private types also not accessible except for fragments that share the same classloader anyways. Because of this also package private members has to be ignored when calculating uses.
1 parent 05d3333 commit fa1bd44

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/search/dependencies/CalculateUsesOperation.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.eclipse.jdt.core.Flags;
3232
import org.eclipse.jdt.core.IField;
3333
import org.eclipse.jdt.core.IJavaProject;
34+
import org.eclipse.jdt.core.IMember;
3435
import org.eclipse.jdt.core.IMethod;
3536
import org.eclipse.jdt.core.IPackageFragment;
3637
import org.eclipse.jdt.core.IType;
@@ -131,8 +132,8 @@ protected void findReferences(IType type, Set<String> pkgs, boolean binary, IPro
131132
if (type == null) {
132133
return;
133134
}
134-
// ignore private classes
135-
if (Flags.isPrivate(type.getFlags())) {
135+
// ignore (package) private classes
136+
if (isBundlePrivateMember(type)) {
136137
return;
137138
}
138139

@@ -142,7 +143,7 @@ protected void findReferences(IType type, Set<String> pkgs, boolean binary, IPro
142143
SubMonitor subMonitor = SubMonitor.convert(monitor, methods.length * 3 + fields.length + 2 + subTypes.length);
143144

144145
for (int i = 0; i < methods.length; i++) {
145-
if (!Flags.isPrivate(methods[i].getFlags())) {
146+
if (!isBundlePrivateMember(methods[i])) {
146147
String methodSignature = methods[i].getSignature();
147148
addPackages(Signature.getThrownExceptionTypes(methodSignature), pkgs, type, binary,
148149
subMonitor.split(1));
@@ -151,7 +152,7 @@ protected void findReferences(IType type, Set<String> pkgs, boolean binary, IPro
151152
}
152153
}
153154
for (int i = 0; i < fields.length; i++) {
154-
if (!Flags.isPrivate(fields[i].getFlags())) {
155+
if (!isBundlePrivateMember(fields[i])) {
155156
addPackage(fields[i].getTypeSignature(), pkgs, type, binary, subMonitor.split(1));
156157
}
157158
}
@@ -164,6 +165,11 @@ protected void findReferences(IType type, Set<String> pkgs, boolean binary, IPro
164165
}
165166
}
166167

168+
private static boolean isBundlePrivateMember(IMember type) throws JavaModelException {
169+
int flags = type.getFlags();
170+
return Flags.isPrivate(flags) || Flags.isPackageDefault(type.getFlags());
171+
}
172+
167173
protected final void addPackage(String typeSignature, Set<String> pkgs, IType type, boolean binary,
168174
IProgressMonitor monitor) throws JavaModelException {
169175
if (typeSignature == null) {

0 commit comments

Comments
 (0)