aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java12
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java30
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IPrivilegedHandler.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java3
-rw-r--r--weaver/src/org/aspectj/weaver/Lint.java3
8 files changed, 45 insertions, 20 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
index 411ae4df5..473e247c2 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
@@ -41,7 +41,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
FieldBinding fieldBinding = (FieldBinding)ref.binding;
makePublic(fieldBinding.declaringClass);
if (isPublic(fieldBinding)) return;
- ref.binding = handler.getPrivilegedAccessField(fieldBinding);
+ ref.binding = handler.getPrivilegedAccessField(fieldBinding, ref);
}
}
@@ -50,7 +50,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
FieldBinding fieldBinding = (FieldBinding)ref.binding;
makePublic(fieldBinding.declaringClass);
if (isPublic(fieldBinding)) return;
- ref.binding = handler.getPrivilegedAccessField(fieldBinding);
+ ref.binding = handler.getPrivilegedAccessField(fieldBinding, ref);
}
}
@@ -59,7 +59,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
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) {
@@ -67,13 +67,13 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
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,
@@ -104,7 +104,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
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 {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
index ecf773c76..d2c02fd02 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
@@ -16,7 +16,9 @@ package org.aspectj.ajdt.internal.compiler.lookup;
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.*;
@@ -29,15 +31,16 @@ public class PrivilegedHandler implements IPrivilegedHandler {
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);
@@ -49,18 +52,37 @@ public class PrivilegedHandler implements IPrivilegedHandler {
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();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
index c32fa6cce..6be97d138 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
@@ -932,7 +932,7 @@ public class BlockScope extends Scope {
if (methodBinding.canBeSeenBy(invocationSite, this)) {
return methodBinding;
} else if (handler != null) {
- return handler.getPrivilegedAccessMethod(methodBinding);
+ return handler.getPrivilegedAccessMethod(methodBinding, (AstNode)invocationSite);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IPrivilegedHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IPrivilegedHandler.java
index 05488ee2d..b2921080a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IPrivilegedHandler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IPrivilegedHandler.java
@@ -11,6 +11,8 @@
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
@@ -20,8 +22,8 @@ package org.eclipse.jdt.internal.compiler.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);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index 75a7662ae..cc0ca8531 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -70,7 +70,7 @@ public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBindin
//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;
@@ -155,7 +155,7 @@ public final boolean canBeSeenBy(Scope scope) {
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;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index a277b2240..da9ff51ce 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -11,6 +11,7 @@
******************************************************************************/
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;
@@ -184,7 +185,7 @@ public abstract class Scope
IPrivilegedHandler handler = findPrivilegedHandler(invocationType());
if (handler != null) {
//???System.err.println("privileged access: ");
- return invocationType().privilegedHandler.getPrivilegedAccessMethod(exactMethod);
+ return invocationType().privilegedHandler.getPrivilegedAccessMethod(exactMethod, (AstNode)invocationSite);
}
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index bfac0b428..a4106b478 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -16,6 +16,7 @@ import java.util.*;
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;
@@ -512,7 +513,7 @@ public FieldBinding getField(char[] fieldName, InvocationSite site, Scope scope)
!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;
diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java
index ce8850754..527dfa0fe 100644
--- a/weaver/src/org/aspectj/weaver/Lint.java
+++ b/weaver/src/org/aspectj/weaver/Lint.java
@@ -36,8 +36,7 @@ public class Lint {
public final Kind typeNotExposedToWeaver =
new Kind("typeNotExposedToWeaver", "this affected type is not exposed to the weaver: {0}");
-
-
+
public Lint(World world) {
this.world = world;
}