Explorar el Código

more fixes for privileged

tags/V_1_1_b2
jhugunin hace 21 años
padre
commit
8d0fab3add

+ 2
- 2
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java Ver fichero



SourceTypeBinding typeBinding = (SourceTypeBinding) binding.declaringClass; SourceTypeBinding typeBinding = (SourceTypeBinding) binding.declaringClass;
TypeDeclaration typeDecl = typeBinding.scope.referenceContext; 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) //what scope to use (depend on the staticness of the field binding)
MethodScope fieldScope = MethodScope fieldScope =
binding.isStatic() binding.isStatic()

+ 8
- 2
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java Ver fichero

ReferenceBinding receiverType, ReferenceBinding receiverType,
TypeBinding[] argumentTypes, TypeBinding[] argumentTypes,
InvocationSite invocationSite) { InvocationSite invocationSite) {
IPrivilegedHandler handler = findPrivilegedHandler(invocationType());


compilationUnitScope().recordTypeReference(receiverType); compilationUnitScope().recordTypeReference(receiverType);
compilationUnitScope().recordTypeReferences(argumentTypes); compilationUnitScope().recordTypeReferences(argumentTypes);
MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
if (methodBinding != null)
if (methodBinding.canBeSeenBy(invocationSite, this))
if (methodBinding != null) {
if (methodBinding.canBeSeenBy(invocationSite, this)) {
return methodBinding; return methodBinding;
} else if (handler != null) {
return handler.getPrivilegedAccessMethod(methodBinding);
}
}


MethodBinding[] methods = MethodBinding[] methods =
receiverType.getMethods(ConstructorDeclaration.ConstantPoolName); receiverType.getMethods(ConstructorDeclaration.ConstantPoolName);

+ 2
- 0
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java Ver fichero

public SyntheticAccessMethodBinding getAccessMethod(boolean isReadAccess) { public SyntheticAccessMethodBinding getAccessMethod(boolean isReadAccess) {
throw new RuntimeException("unimplemented"); throw new RuntimeException("unimplemented");
} }

public FieldBinding getFieldBindingForLookup() { return this; }
} }

+ 5
- 4
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java Ver fichero

public boolean canBeSeenBy(InvocationSite invocationSite, Scope scope) { public boolean canBeSeenBy(InvocationSite invocationSite, Scope scope) {
if (isPublic()) return true; if (isPublic()) return true;


SourceTypeBinding invocationType = scope.enclosingSourceType();
SourceTypeBinding invocationType = scope.invocationType();
if (invocationType == declaringClass) return true; if (invocationType == declaringClass) return true;


if (isProtected()) { if (isProtected()) {
*/ */
public boolean canBeSeenBy(TypeBinding receiverType, InvocationSite invocationSite, Scope scope) { public boolean canBeSeenBy(TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
if (isPublic()) return true; 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 (invocationType == declaringClass && invocationType == receiverType) return true;


if (isProtected()) { if (isProtected()) {
if (invocationType == declaringClass) return true; if (invocationType == declaringClass) return true;
if (invocationType.fPackage == declaringClass.fPackage) 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; int depth = 0;
do { do {
if (declaringClass.isSuperclassOf(currentType)) { if (declaringClass.isSuperclassOf(currentType)) {

+ 9
- 10
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java Ver fichero



public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) { public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) {
boolean ret = innerCanBeSeenBy(receiverType, 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) { private final boolean innerCanBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) {

Cargando…
Cancelar
Guardar