Java Code Examples for org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants#AccProtected
The following examples show how to use
org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants#AccProtected .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HandleFieldDefaults.java From EasyMPermission with MIT License | 6 votes |
public void setFieldDefaultsForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean makeFinal) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); if (level != null && level != AccessLevel.NONE) { if ((field.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected)) == 0) { if (!hasAnnotation(PackagePrivate.class, fieldNode)) { field.modifiers |= EclipseHandlerUtil.toEclipseModifier(level); } } } if (makeFinal && (field.modifiers & ClassFileConstants.AccFinal) == 0) { if (!hasAnnotation(NonFinal.class, fieldNode)) { field.modifiers |= ClassFileConstants.AccFinal; } } fieldNode.rebuild(); }
Example 2
Source File: EclipseHandlerUtil.java From EasyMPermission with MIT License | 6 votes |
/** * Turns an {@code AccessLevel} instance into the flag bit used by eclipse. */ public static int toEclipseModifier(AccessLevel value) { switch (value) { case MODULE: case PACKAGE: return 0; default: case PUBLIC: return ClassFileConstants.AccPublic; case PROTECTED: return ClassFileConstants.AccProtected; case NONE: case PRIVATE: return ClassFileConstants.AccPrivate; } }
Example 3
Source File: CodeSnippetScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { ReferenceBinding object = getJavaLangObject(); MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null); if (methodBinding != null) { // handle the method clone() specially... cannot be protected or throw exceptions if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE)) return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object); if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) return methodBinding; } // answers closest approximation, may not check argumentTypes or visibility methodBinding = findMethod(object, selector, argumentTypes, invocationSite, false); if (methodBinding == null) return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound); if (methodBinding.isValidBinding()) { MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite, Scope.FULL_INFERENCE); if (compatibleMethod == null) return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound); methodBinding = compatibleMethod; if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible); } return methodBinding; }
Example 4
Source File: ASTNode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static StringBuffer printModifiers(int modifiers, StringBuffer output) { if ((modifiers & ClassFileConstants.AccPublic) != 0) output.append("public "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccPrivate) != 0) output.append("private "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccProtected) != 0) output.append("protected "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccStatic) != 0) output.append("static "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccFinal) != 0) output.append("final "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccSynchronized) != 0) output.append("synchronized "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccVolatile) != 0) output.append("volatile "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccTransient) != 0) output.append("transient "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccNative) != 0) output.append("native "); //$NON-NLS-1$ if ((modifiers & ClassFileConstants.AccAbstract) != 0) output.append("abstract "); //$NON-NLS-1$ if ((modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0) output.append("default "); //$NON-NLS-1$ return output; }
Example 5
Source File: Util.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the outer most enclosing type's visibility for the given TypeDeclaration * and visibility based on compiler options. */ public static int computeOuterMostVisibility(TypeDeclaration typeDeclaration, int visibility) { while (typeDeclaration != null) { switch (typeDeclaration.modifiers & ExtraCompilerModifiers.AccVisibilityMASK) { case ClassFileConstants.AccPrivate: visibility = ClassFileConstants.AccPrivate; break; case ClassFileConstants.AccDefault: if (visibility != ClassFileConstants.AccPrivate) { visibility = ClassFileConstants.AccDefault; } break; case ClassFileConstants.AccProtected: if (visibility == ClassFileConstants.AccPublic) { visibility = ClassFileConstants.AccProtected; } break; } typeDeclaration = typeDeclaration.enclosingType; } return visibility; }
Example 6
Source File: Javadoc.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns whether a type can be seen at a given visibility level or not. * * @param visibility Level of visiblity allowed to see references * @param modifiers modifiers of java element to be seen * @return true if the type can be seen, false otherwise */ boolean canBeSeen(int visibility, int modifiers) { if (modifiers < 0) return true; switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) { case ClassFileConstants.AccPublic : return true; case ClassFileConstants.AccProtected: return (visibility != ClassFileConstants.AccPublic); case ClassFileConstants.AccDefault: return (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate); case ClassFileConstants.AccPrivate: return (visibility == ClassFileConstants.AccPrivate); } return true; }
Example 7
Source File: LookupEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public MethodBinding computeArrayClone(MethodBinding objectClone) { if (this.arrayClone == null) { this.arrayClone = new MethodBinding( (objectClone.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, objectClone.returnType, Binding.NO_PARAMETERS, Binding.NO_EXCEPTIONS, // no exception for array specific method (ReferenceBinding)objectClone.returnType); } return this.arrayClone; }
Example 8
Source File: CompilerOptions.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public String getVisibilityString(int level) { switch (level & ExtraCompilerModifiers.AccVisibilityMASK) { case ClassFileConstants.AccPublic: return PUBLIC; case ClassFileConstants.AccProtected: return PROTECTED; case ClassFileConstants.AccPrivate: return PRIVATE; default: return DEFAULT; } }
Example 9
Source File: Factory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static void decodeModifiers(Set<Modifier> result, int modifiers, int[] checkBits) { if (checkBits == null) return; for (int i = 0, max = checkBits.length; i < max; i++) { switch(checkBits[i]) { case ClassFileConstants.AccPublic : appendModifier(result, modifiers, checkBits[i], Modifier.PUBLIC); break; case ClassFileConstants.AccProtected: appendModifier(result, modifiers, checkBits[i], Modifier.PROTECTED); break; case ClassFileConstants.AccPrivate : appendModifier(result, modifiers, checkBits[i], Modifier.PRIVATE); break; case ClassFileConstants.AccAbstract : appendModifier(result, modifiers, checkBits[i], Modifier.ABSTRACT); break; case ExtraCompilerModifiers.AccDefaultMethod : try { appendModifier(result, modifiers, checkBits[i], Modifier.valueOf("DEFAULT")); //$NON-NLS-1$ } catch(IllegalArgumentException iae) { // Don't have JDK 1.8, just ignore and proceed. } break; case ClassFileConstants.AccStatic : appendModifier(result, modifiers, checkBits[i], Modifier.STATIC); break; case ClassFileConstants.AccFinal : appendModifier(result, modifiers, checkBits[i], Modifier.FINAL); break; case ClassFileConstants.AccSynchronized : appendModifier(result, modifiers, checkBits[i], Modifier.SYNCHRONIZED); break; case ClassFileConstants.AccNative : appendModifier(result, modifiers, checkBits[i], Modifier.NATIVE); break; case ClassFileConstants.AccStrictfp : appendModifier(result, modifiers, checkBits[i], Modifier.STRICTFP); break; case ClassFileConstants.AccTransient : appendModifier(result, modifiers, checkBits[i], Modifier.TRANSIENT); break; case ClassFileConstants.AccVolatile : appendModifier(result, modifiers, checkBits[i], Modifier.VOLATILE); break; } } }
Example 10
Source File: ReferenceBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Answer true if the receiver has default visibility */ public final boolean isDefault() { return (this.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate)) == 0; }
Example 11
Source File: ReferenceBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Answer true if the receiver has protected visibility */ public final boolean isProtected() { return (this.modifiers & ClassFileConstants.AccProtected) != 0; }
Example 12
Source File: MethodBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public final boolean isProtected() { return (this.modifiers & ClassFileConstants.AccProtected) != 0; }
Example 13
Source File: MethodScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Spec : 8.4.3 & 9.4 */ private void checkAndSetModifiersForConstructor(MethodBinding methodBinding) { int modifiers = methodBinding.modifiers; final ReferenceBinding declaringClass = methodBinding.declaringClass; if ((modifiers & ExtraCompilerModifiers.AccAlternateModifierProblem) != 0) problemReporter().duplicateModifierForMethod(declaringClass, (AbstractMethodDeclaration) this.referenceContext); if ((((ConstructorDeclaration) this.referenceContext).bits & ASTNode.IsDefaultConstructor) != 0) { // certain flags are propagated from declaring class onto constructor final int DECLARING_FLAGS = ClassFileConstants.AccEnum|ClassFileConstants.AccPublic|ClassFileConstants.AccProtected; final int VISIBILITY_FLAGS = ClassFileConstants.AccPrivate|ClassFileConstants.AccPublic|ClassFileConstants.AccProtected; int flags; if ((flags = declaringClass.modifiers & DECLARING_FLAGS) != 0) { if ((flags & ClassFileConstants.AccEnum) != 0) { modifiers &= ~VISIBILITY_FLAGS; modifiers |= ClassFileConstants.AccPrivate; // default constructor is implicitly private in enum } else { modifiers &= ~VISIBILITY_FLAGS; modifiers |= flags; // propagate public/protected } } } // after this point, tests on the 16 bits reserved. int realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag; // check for abnormal modifiers final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStrictfp); if (declaringClass.isEnum() && (((ConstructorDeclaration) this.referenceContext).bits & ASTNode.IsDefaultConstructor) == 0) { final int UNEXPECTED_ENUM_CONSTR_MODIFIERS = ~(ClassFileConstants.AccPrivate | ClassFileConstants.AccStrictfp); if ((realModifiers & UNEXPECTED_ENUM_CONSTR_MODIFIERS) != 0) { problemReporter().illegalModifierForEnumConstructor((AbstractMethodDeclaration) this.referenceContext); modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_ENUM_CONSTR_MODIFIERS; } else if ((((AbstractMethodDeclaration) this.referenceContext).modifiers & ClassFileConstants.AccStrictfp) != 0) { // must check the parse node explicitly problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) this.referenceContext); } modifiers |= ClassFileConstants.AccPrivate; // enum constructor is implicitly private } else if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) { problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) this.referenceContext); modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_MODIFIERS; } else if ((((AbstractMethodDeclaration) this.referenceContext).modifiers & ClassFileConstants.AccStrictfp) != 0) { // must check the parse node explicitly problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) this.referenceContext); } // check for incompatible modifiers in the visibility bits, isolate the visibility bits int accessorBits = realModifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate); if ((accessorBits & (accessorBits - 1)) != 0) { problemReporter().illegalVisibilityModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) this.referenceContext); // need to keep the less restrictive so disable Protected/Private as necessary if ((accessorBits & ClassFileConstants.AccPublic) != 0) { if ((accessorBits & ClassFileConstants.AccProtected) != 0) modifiers &= ~ClassFileConstants.AccProtected; if ((accessorBits & ClassFileConstants.AccPrivate) != 0) modifiers &= ~ClassFileConstants.AccPrivate; } else if ((accessorBits & ClassFileConstants.AccProtected) != 0 && (accessorBits & ClassFileConstants.AccPrivate) != 0) { modifiers &= ~ClassFileConstants.AccPrivate; } } // // if the receiver's declaring class is a private nested type, then make sure the receiver is not private (causes problems for inner type emulation) // if (declaringClass.isPrivate() && (modifiers & ClassFileConstants.AccPrivate) != 0) // modifiers &= ~ClassFileConstants.AccPrivate; methodBinding.modifiers = modifiers; }
Example 14
Source File: MethodScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Spec : 8.4.3 & 9.4 */ private void checkAndSetModifiersForMethod(MethodBinding methodBinding) { int modifiers = methodBinding.modifiers; final ReferenceBinding declaringClass = methodBinding.declaringClass; if ((modifiers & ExtraCompilerModifiers.AccAlternateModifierProblem) != 0) problemReporter().duplicateModifierForMethod(declaringClass, (AbstractMethodDeclaration) this.referenceContext); // after this point, tests on the 16 bits reserved. int realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag; // set the requested modifiers for a method in an interface/annotation if (declaringClass.isInterface()) { int expectedModifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract; boolean isDefaultMethod = (modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0; // no need to check validity, is done by the parser boolean reportIllegalModifierCombination = false; boolean isJDK18orGreater = false; if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8 && !declaringClass.isAnnotationType()) { expectedModifiers |= ClassFileConstants.AccStrictfp | ExtraCompilerModifiers.AccDefaultMethod | ClassFileConstants.AccStatic; isJDK18orGreater = true; if (!methodBinding.isAbstract()) { reportIllegalModifierCombination = isDefaultMethod && methodBinding.isStatic(); } else { reportIllegalModifierCombination = isDefaultMethod || methodBinding.isStatic(); if (methodBinding.isStrictfp()) { problemReporter().illegalAbstractModifierCombinationForMethod((AbstractMethodDeclaration) this.referenceContext); } } if (reportIllegalModifierCombination) { problemReporter().illegalModifierCombinationForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext); } // Kludge - The AccDefaultMethod bit is outside the lower 16 bits and got removed earlier. Putting it back. if (isDefaultMethod) { realModifiers |= ExtraCompilerModifiers.AccDefaultMethod; } } if ((realModifiers & ~expectedModifiers) != 0) { if ((declaringClass.modifiers & ClassFileConstants.AccAnnotation) != 0) problemReporter().illegalModifierForAnnotationMember((AbstractMethodDeclaration) this.referenceContext); else problemReporter().illegalModifierForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext, isJDK18orGreater); } return; } // check for abnormal modifiers final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccAbstract | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccSynchronized | ClassFileConstants.AccNative | ClassFileConstants.AccStrictfp); if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) { problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) this.referenceContext); modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_MODIFIERS; } // check for incompatible modifiers in the visibility bits, isolate the visibility bits int accessorBits = realModifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate); if ((accessorBits & (accessorBits - 1)) != 0) { problemReporter().illegalVisibilityModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) this.referenceContext); // need to keep the less restrictive so disable Protected/Private as necessary if ((accessorBits & ClassFileConstants.AccPublic) != 0) { if ((accessorBits & ClassFileConstants.AccProtected) != 0) modifiers &= ~ClassFileConstants.AccProtected; if ((accessorBits & ClassFileConstants.AccPrivate) != 0) modifiers &= ~ClassFileConstants.AccPrivate; } else if ((accessorBits & ClassFileConstants.AccProtected) != 0 && (accessorBits & ClassFileConstants.AccPrivate) != 0) { modifiers &= ~ClassFileConstants.AccPrivate; } } // check for modifiers incompatible with abstract modifier if ((modifiers & ClassFileConstants.AccAbstract) != 0) { int incompatibleWithAbstract = ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccSynchronized | ClassFileConstants.AccNative | ClassFileConstants.AccStrictfp; if ((modifiers & incompatibleWithAbstract) != 0) problemReporter().illegalAbstractModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) this.referenceContext); if (!methodBinding.declaringClass.isAbstract()) problemReporter().abstractMethodInAbstractClass((SourceTypeBinding) declaringClass, (AbstractMethodDeclaration) this.referenceContext); } /* DISABLED for backward compatibility with javac (if enabled should also mark private methods as final) // methods from a final class are final : 8.4.3.3 if (methodBinding.declaringClass.isFinal()) modifiers |= AccFinal; */ // native methods cannot also be tagged as strictfp if ((modifiers & ClassFileConstants.AccNative) != 0 && (modifiers & ClassFileConstants.AccStrictfp) != 0) problemReporter().nativeMethodsCannotBeStrictfp(declaringClass, (AbstractMethodDeclaration) this.referenceContext); // static members are only authorized in a static member or top level type if (((realModifiers & ClassFileConstants.AccStatic) != 0) && declaringClass.isNestedType() && !declaringClass.isStatic()) problemReporter().unexpectedStaticModifierForMethod(declaringClass, (AbstractMethodDeclaration) this.referenceContext); methodBinding.modifiers = modifiers; }
Example 15
Source File: FieldBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public final boolean isProtected() { return (this.modifiers & ClassFileConstants.AccProtected) != 0; }