From 96db4fbc4c83aac5411e25199ea237584b836036 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Wed, 18 Dec 2002 01:36:31 +0000 Subject: [PATCH] more privileged fixes --- .../compiler/lookup/IPrivilegedHandler.java | 1 + .../compiler/lookup/MethodBinding.java | 2 +- .../compiler/lookup/ReferenceBinding.java | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) 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 fe118ec97..05488ee2d 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 @@ -23,4 +23,5 @@ public interface IPrivilegedHandler { FieldBinding getPrivilegedAccessField(FieldBinding baseField); MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod); + void notePrivilegedTypeAccess(ReferenceBinding type); } 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 db6579e6e..81cc19cdd 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 @@ -136,7 +136,7 @@ public boolean canBeSeenBy(InvocationSite invocationSite, Scope scope) { public boolean canBeSeenBy(TypeBinding receiverType, InvocationSite invocationSite, Scope scope) { if (isPublic()) return true; - SourceTypeBinding invocationType = scope.enclosingSourceType(); + SourceTypeBinding invocationType = scope.invocationType(); //enclosingSourceType(); if (invocationType == declaringClass && invocationType == receiverType) return true; if (isProtected()) { 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 e4899616b..16e7c433c 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 @@ -64,6 +64,20 @@ 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; +} + +private final boolean innerCanBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) { if (isPublic()) return true; if (invocationType == this && invocationType == receiverType) return true; @@ -132,10 +146,28 @@ public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBindin */ public final boolean canBeSeenBy(Scope scope) { + boolean ret = innerCanBeSeenBy(scope); + if (ret) return true; + + SourceTypeBinding invocationType = scope.invocationType(); +// System.err.println("trying to see (scope): " + new String(sourceName) + +// " from " + new String(invocationType.sourceName)); + + + if (invocationType.privilegedHandler != null) { + //System.err.println(" is privileged!"); + invocationType.privilegedHandler.notePrivilegedTypeAccess(this); + return true; + } + return false; +} + +private final boolean innerCanBeSeenBy(Scope scope) { if (isPublic()) return true; SourceTypeBinding invocationType = scope.enclosingSourceType(); if (invocationType == this) return true; + if (isProtected()) { // answer true if the invocationType is the declaringClass or they are in the same package -- 2.39.5