FieldBinding fieldBinding = (FieldBinding)ref.binding;
makePublic(fieldBinding.declaringClass);
if (isPublic(fieldBinding)) return;
- ref.binding = handler.getPrivilegedAccessField(fieldBinding);
+ ref.binding = handler.getPrivilegedAccessField(fieldBinding, ref);
}
}
FieldBinding fieldBinding = (FieldBinding)ref.binding;
makePublic(fieldBinding.declaringClass);
if (isPublic(fieldBinding)) return;
- ref.binding = handler.getPrivilegedAccessField(fieldBinding);
+ ref.binding = handler.getPrivilegedAccessField(fieldBinding, ref);
}
}
FieldBinding fieldBinding = (FieldBinding)ref.binding;
makePublic(fieldBinding.declaringClass);
if (isPublic(fieldBinding)) return;
- ref.binding = handler.getPrivilegedAccessField(fieldBinding);
+ ref.binding = handler.getPrivilegedAccessField(fieldBinding, ref);
}
}
public void endVisit(MessageSend send, BlockScope scope) {
if (send.binding == null) return;
if (isPublic(send.binding)) return;
makePublic(send.binding.declaringClass);
- send.binding = send.codegenBinding = handler.getPrivilegedAccessMethod(send.binding);
+ send.binding = send.codegenBinding = handler.getPrivilegedAccessMethod(send.binding, send);
}
public void endVisit(AllocationExpression send, BlockScope scope) {
if (send.binding == null) return;
if (isPublic(send.binding)) return;
makePublic(send.binding.declaringClass);
- send.binding = handler.getPrivilegedAccessMethod(send.binding);
+ send.binding = handler.getPrivilegedAccessMethod(send.binding, send);
}
public void endVisit(
QualifiedTypeReference ref,
private void makePublic(TypeBinding binding) {
if (binding instanceof ReferenceBinding) {
ReferenceBinding rb = (ReferenceBinding)binding;
- if (!rb.isPublic()) handler.notePrivilegedTypeAccess(rb);
+ if (!rb.isPublic()) handler.notePrivilegedTypeAccess(rb, null); //???
} else if (binding instanceof ArrayBinding) {
makePublic( ((ArrayBinding)binding).leafComponentType );
} else {
import java.util.*;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
+import org.aspectj.bridge.ISourceLocation;
import org.aspectj.weaver.*;
+import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.lookup.*;
this.inAspect = inAspect;
}
- public FieldBinding getPrivilegedAccessField(FieldBinding baseField) {
+ public FieldBinding getPrivilegedAccessField(FieldBinding baseField, AstNode location) {
ResolvedMember key = inAspect.world.makeResolvedMember(baseField);
if (accessors.containsKey(key)) return (FieldBinding)accessors.get(key);
FieldBinding ret = new PrivilegedFieldBinding(inAspect, baseField);
+ checkWeaveAccess(key.getDeclaringType(), location);
accessors.put(key, ret);
return ret;
}
- public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod) {
+ public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod, AstNode location) {
ResolvedMember key = inAspect.world.makeResolvedMember(baseMethod);
if (accessors.containsKey(key)) return (MethodBinding)accessors.get(key);
AjcMemberMaker.privilegedAccessMethodForMethod(inAspect.typeX, key)
);
}
-
+ checkWeaveAccess(key.getDeclaringType(), location);
//new PrivilegedMethodBinding(inAspect, baseMethod);
accessors.put(key, ret);
return ret;
}
- public void notePrivilegedTypeAccess(ReferenceBinding type) {
+ public void notePrivilegedTypeAccess(ReferenceBinding type, AstNode location) {
ResolvedMember key =
new ResolvedMember(Member.STATIC_INITIALIZATION,
inAspect.world.fromEclipse(type), 0, ResolvedTypeX.VOID, "", TypeX.NONE);
+
+ checkWeaveAccess(key.getDeclaringType(), location);
accessors.put(key, key);
}
+
+ private void checkWeaveAccess(TypeX typeX, AstNode location) {
+ World world = inAspect.world;
+ Lint.Kind check = world.getLint().typeNotExposedToWeaver;
+ if (check.isEnabled()) {
+ if (!world.resolve(typeX).isExposedToWeaver()) {
+ ISourceLocation loc = null;
+ if (location != null) {
+ loc = new EclipseSourceLocation(inAspect.compilationResult,
+ location.sourceStart, location.sourceEnd);
+ }
+ check.signal(typeX.getName() + " (needed for privileged access)",
+ loc);
+ }
+ }
+ }
+
public ResolvedMember[] getMembers() {
Collection m = accessors.keySet();
if (methodBinding.canBeSeenBy(invocationSite, this)) {
return methodBinding;
} else if (handler != null) {
- return handler.getPrivilegedAccessMethod(methodBinding);
+ return handler.getPrivilegedAccessMethod(methodBinding, (AstNode)invocationSite);
}
}
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.internal.compiler.ast.AstNode;
+
/**
* This interface is used by SourceTypeBinding to provide a delegated lookup
*/
public interface IPrivilegedHandler {
- FieldBinding getPrivilegedAccessField(FieldBinding baseField);
+ FieldBinding getPrivilegedAccessField(FieldBinding baseField, AstNode location);
- MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod);
- void notePrivilegedTypeAccess(ReferenceBinding type);
+ MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod, AstNode location);
+ void notePrivilegedTypeAccess(ReferenceBinding type, AstNode location);
}
//System.err.println("trying to see: " + new String(sourceName));
if (Scope.findPrivilegedHandler(invocationType) != null) {
- Scope.findPrivilegedHandler(invocationType).notePrivilegedTypeAccess(this);
+ Scope.findPrivilegedHandler(invocationType).notePrivilegedTypeAccess(this, null);
return true;
}
return false;
if (Scope.findPrivilegedHandler(invocationType) != null) {
//System.err.println(" is privileged!");
- Scope.findPrivilegedHandler(invocationType).notePrivilegedTypeAccess(this);
+ Scope.findPrivilegedHandler(invocationType).notePrivilegedTypeAccess(this, null);
return true;
}
return false;
******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
IPrivilegedHandler handler = findPrivilegedHandler(invocationType());
if (handler != null) {
//???System.err.println("privileged access: ");
- return invocationType().privilegedHandler.getPrivilegedAccessMethod(exactMethod);
+ return invocationType().privilegedHandler.getPrivilegedAccessMethod(exactMethod, (AstNode)invocationSite);
}
}
}
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.AssertStatement;
+import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
!ret.canBeSeenBy(this, site, scope))
{
//System.err.println("privileged access: " + new String(fieldName));
- return handler.getPrivilegedAccessField(ret);
+ return handler.getPrivilegedAccessField(ret, (AstNode)site);
}
}
return ret;
public final Kind typeNotExposedToWeaver =
new Kind("typeNotExposedToWeaver", "this affected type is not exposed to the weaver: {0}");
-
-
+
public Lint(World world) {
this.world = world;
}