public boolean isNestmateOf(ReferenceBinding other) { SourceTypeBinding s1 = getSourceTypeBinding(this); SourceTypeBinding s2 = getSourceTypeBinding(other); if (s1 == null || s2 == null) return false; return s1.isNestmateOf(s2); }
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { // if constructor from parameterized type got found, use the original constructor at codegen time MethodBinding codegenBinding = this.binding.original(); // perform some emulation work in case there is some and we are inside a local type only if (this.binding.isPrivate() && !currentScope.enclosingSourceType().isNestmateOf(this.binding.declaringClass) && this.accessMode != ExplicitConstructorCall.This) { ReferenceBinding declaringClass = codegenBinding.declaringClass; // from 1.4 on, local type constructor can lose their private flag to ease emulation if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { // constructor will not be dumped as private, no emulation required thus codegenBinding.tagBits |= TagBits.ClearPrivateModifier; } else { this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess()); currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); } } } }
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return; // if constructor from parameterized type got found, use the original constructor at codegen time MethodBinding codegenBinding = this.binding.original(); ReferenceBinding declaringClass; if (codegenBinding.isPrivate() && !currentScope.enclosingSourceType().isNestmateOf(this.binding.declaringClass) && TypeBinding.notEquals(currentScope.enclosingSourceType(), (declaringClass = codegenBinding.declaringClass))) { // from 1.4 on, local type constructor can lose their private flag to ease emulation if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { // constructor will not be dumped as private, no emulation required thus codegenBinding.tagBits |= TagBits.ClearPrivateModifier; } else { this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess()); currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); } } }
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo, boolean isReadAccess) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return; //If inlinable field, forget the access emulation, the code gen will directly target it if (this.constant != Constant.NotAConstant) return; if ((this.bits & Binding.FIELD) != 0) { FieldBinding fieldBinding = (FieldBinding) this.binding; FieldBinding codegenField = fieldBinding.original(); if (((this.bits & ASTNode.DepthMASK) != 0) && ((codegenField.isPrivate() // private access && !currentScope.enclosingSourceType().isNestmateOf(codegenField.declaringClass) ) || (codegenField.isProtected() // implicit protected access && codegenField.declaringClass.getPackage() != currentScope.enclosingSourceType().getPackage()))) { if (this.syntheticAccessors == null) this.syntheticAccessors = new MethodBinding[2]; this.syntheticAccessors[isReadAccess ? SingleNameReference.READ : SingleNameReference.WRITE] = ((SourceTypeBinding)currentScope.enclosingSourceType(). enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT)).addSyntheticMethod(codegenField, isReadAccess, false /*not super access*/); currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, isReadAccess); return; } } }
FieldBinding codegenField = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index); ReferenceBinding declaringClass = codegenField.declaringClass; if (!currentScope.enclosingSourceType().isNestmateOf(declaringClass) && TypeBinding.notEquals(declaringClass, currentScope.enclosingSourceType())) { setSyntheticAccessor(fieldBinding, index, ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenField, index >= 0 /*read-access?*/, false /*not super access*/));
if (!currentScope.enclosingSourceType().isNestmateOf(codegenBinding.declaringClass) && TypeBinding.notEquals(currentScope.enclosingSourceType(), codegenBinding.declaringClass)){ this.syntheticAccessor = ((SourceTypeBinding)codegenBinding.declaringClass).addSyntheticMethod(codegenBinding, false /* not super access there */);
if (!currentScope.enclosingSourceType().isNestmateOf(codegenBinding.declaringClass) && (TypeBinding.notEquals(currentScope.enclosingSourceType(), codegenBinding.declaringClass)) && this.binding.constant(currentScope) == Constant.NotAConstant) {
codegenBinding.tagBits |= TagBits.ClearPrivateModifier; } else { if (currentScope.enclosingSourceType().isNestmateOf(this.binding.declaringClass)) { this.syntheticAccessor = codegenBinding; return;
codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass, this.typeArguments); } else if((this.receiver.isSuper()) || (!currentScope.enclosingSourceType().isNestmateOf(this.binding.declaringClass) && codegenBinding.isPrivate())){ codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, constantPoolDeclaringClass, this.typeArguments); } else if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type