diff options
author | jhugunin <jhugunin> | 2002-12-18 05:07:05 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2002-12-18 05:07:05 +0000 |
commit | 8d0fab3add4dea0648b7574df1dfd6f4c856b7a1 (patch) | |
tree | e478038e6c6a0eb1d59b1ae7614ad18888ebccf9 /org.eclipse.jdt.core | |
parent | 07f68f155d55b52902118bfa8f2747142de79b09 (diff) | |
download | aspectj-8d0fab3add4dea0648b7574df1dfd6f4c856b7a1.tar.gz aspectj-8d0fab3add4dea0648b7574df1dfd6f4c856b7a1.zip |
more fixes for privileged
Diffstat (limited to 'org.eclipse.jdt.core')
5 files changed, 26 insertions, 18 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java index 9624fb768..d95830ad7 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java @@ -333,8 +333,8 @@ public class FieldReference extends Reference implements InvocationSite { SourceTypeBinding typeBinding = (SourceTypeBinding) binding.declaringClass; TypeDeclaration typeDecl = typeBinding.scope.referenceContext; - FieldDeclaration fieldDecl = typeDecl.declarationOf(binding); - + FieldDeclaration fieldDecl = typeDecl.declarationOf(binding.getFieldBindingForLookup()); + //System.err.println(typeDecl + " and " + fieldDecl + ", " + binding); //what scope to use (depend on the staticness of the field binding) MethodScope fieldScope = binding.isStatic() 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 7e795e38c..c32fa6cce 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 @@ -922,13 +922,19 @@ public class BlockScope extends Scope { ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) { + + IPrivilegedHandler handler = findPrivilegedHandler(invocationType()); compilationUnitScope().recordTypeReference(receiverType); compilationUnitScope().recordTypeReferences(argumentTypes); MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); - if (methodBinding != null) - if (methodBinding.canBeSeenBy(invocationSite, this)) + if (methodBinding != null) { + if (methodBinding.canBeSeenBy(invocationSite, this)) { return methodBinding; + } else if (handler != null) { + return handler.getPrivilegedAccessMethod(methodBinding); + } + } MethodBinding[] methods = receiverType.getMethods(ConstructorDeclaration.ConstantPoolName); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java index 81e55d1e8..166a3e55c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java @@ -215,4 +215,6 @@ public boolean alwaysNeedsAccessMethod(boolean isReadAccess) { return false; } public SyntheticAccessMethodBinding getAccessMethod(boolean isReadAccess) { throw new RuntimeException("unimplemented"); } + +public FieldBinding getFieldBindingForLookup() { return this; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java index 81cc19cdd..34f38282c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java @@ -96,7 +96,7 @@ public final int bindingType() { public boolean canBeSeenBy(InvocationSite invocationSite, Scope scope) { if (isPublic()) return true; - SourceTypeBinding invocationType = scope.enclosingSourceType(); + SourceTypeBinding invocationType = scope.invocationType(); if (invocationType == declaringClass) return true; if (isProtected()) { @@ -135,8 +135,8 @@ public boolean canBeSeenBy(InvocationSite invocationSite, Scope scope) { */ public boolean canBeSeenBy(TypeBinding receiverType, InvocationSite invocationSite, Scope scope) { if (isPublic()) return true; - - SourceTypeBinding invocationType = scope.invocationType(); //enclosingSourceType(); + //XXX invocation vs. source + SourceTypeBinding invocationType = scope.invocationType(); if (invocationType == declaringClass && invocationType == receiverType) return true; if (isProtected()) { @@ -148,7 +148,8 @@ public boolean canBeSeenBy(TypeBinding receiverType, InvocationSite invocationSi if (invocationType == declaringClass) return true; if (invocationType.fPackage == declaringClass.fPackage) return true; - ReferenceBinding currentType = invocationType; + // for protected we need to check based on the type of this + ReferenceBinding currentType = scope.enclosingSourceType();; int depth = 0; do { if (declaringClass.isSuperclassOf(currentType)) { 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 16e7c433c..69507b775 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 @@ -65,16 +65,15 @@ public final boolean canBeSeenBy(PackageBinding invocationPackage) { public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) { boolean ret = innerCanBeSeenBy(receiverType, invocationType); - return ret; -// if (ret) return true; -// -// System.err.println("trying to see: " + new String(sourceName)); -// -// if (invocationType.privilegedHandler != null) { -// invocationType.privilegedHandler.notePrivilegedTypeAccess(this); -// return true; -// } -// return false; + if (ret) return true; + + //System.err.println("trying to see: " + new String(sourceName)); + + if (invocationType.privilegedHandler != null) { + invocationType.privilegedHandler.notePrivilegedTypeAccess(this); + return true; + } + return false; } private final boolean innerCanBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) { |