List of usage examples for org.objectweb.asm Opcodes ACC_PROTECTED
int ACC_PROTECTED
To view the source code for org.objectweb.asm Opcodes ACC_PROTECTED.
Click Source Link
From source file:org.spockframework.compiler.SpecRewriter.java
License:Apache License
private static void makeSharedFieldProtectedAndVolatile(Field field) { AstUtil.setVisibility(field.getAst(), Opcodes.ACC_PROTECTED); field.getAst().setModifiers(field.getAst().getModifiers() | Opcodes.ACC_VOLATILE); }
From source file:org.spongepowered.asm.util.SignaturePrinter.java
License:MIT License
public void setModifiers(MethodNode method) { String returnType = SignaturePrinter.getTypeName(Type.getReturnType(method.desc), false); if ((method.access & Opcodes.ACC_PUBLIC) != 0) { this.setModifiers("public " + returnType); } else if ((method.access & Opcodes.ACC_PROTECTED) != 0) { this.setModifiers("protected " + returnType); } else if ((method.access & Opcodes.ACC_PRIVATE) != 0) { this.setModifiers("private " + returnType); } else {/*from w w w .ja va2 s. c o m*/ this.setModifiers(returnType); } }
From source file:org.springframework.boot.cli.command.ScriptCompilationCustomizer.java
License:Apache License
/** * If the script defines a block in this form: * //from w w w. j ava 2s . c om * <pre> * options { * option "foo", "My Foo option" * option "bar", "Bar has a value" withOptionalArg() ofType Integer * } * </pre> * * Then the block is taken and used to override the {@link OptionHandler#options()} * method. In the example "option" is a call to * {@link OptionHandler#option(String, String)}, and hence returns an * {@link OptionSpecBuilder}. Makes a nice readable DSL for adding options. * * @param source the source node * @param classNode the class node to manipulate */ private void overrideOptionsMethod(SourceUnit source, ClassNode classNode) { BlockStatement block = source.getAST().getStatementBlock(); List<Statement> statements = block.getStatements(); for (Statement statement : new ArrayList<Statement>(statements)) { if (statement instanceof ExpressionStatement) { ExpressionStatement expr = (ExpressionStatement) statement; Expression expression = expr.getExpression(); if (expression instanceof MethodCallExpression) { MethodCallExpression method = (MethodCallExpression) expression; if (method.getMethod().getText().equals("options")) { expression = method.getArguments(); if (expression instanceof ArgumentListExpression) { ArgumentListExpression arguments = (ArgumentListExpression) expression; expression = arguments.getExpression(0); if (expression instanceof ClosureExpression) { ClosureExpression closure = (ClosureExpression) expression; classNode.addMethod( new MethodNode("options", Opcodes.ACC_PROTECTED, ClassHelper.VOID_TYPE, new Parameter[0], new ClassNode[0], closure.getCode())); statements.remove(statement); } } } } } } }
From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtils.java
License:Apache License
/** * Converts the given bitwise ORed <code>modifiers</code> into a {@link String}. * //from www .j a v a 2 s.co m * <p/> * * The returned String should reflect the ordering recommended in the JLS: * * <ul> * <li>Classes: <code>public protected private abstract static final strictfp</code></li> * <li>Fields: <code>public protected private static final transient volatile</code></li> * <li>Constructors: <code>public protected private</code></li> * <li>Methods: <code>public protected private abstract static final synchronized native strictfp</code></li> * </ul> * * @param modifiers the modifiers * * @return The String representation of the modifiers * * @see Opcodes */ // CHECKSTYLE:OFF static final String modifiersToString(int modifiers) { StringBuilder accessBuilder = new StringBuilder(); if ((modifiers & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) { accessBuilder.append("public "); } if ((modifiers & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED) { accessBuilder.append("protected "); } if ((modifiers & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) { accessBuilder.append("private "); } if ((modifiers & Opcodes.ACC_ABSTRACT) == Opcodes.ACC_ABSTRACT) { accessBuilder.append("abstract "); } if ((modifiers & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) { accessBuilder.append("static "); } if ((modifiers & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL) { accessBuilder.append("final "); } if ((modifiers & Opcodes.ACC_SYNCHRONIZED) == Opcodes.ACC_SYNCHRONIZED) { accessBuilder.append("synchronized "); } if ((modifiers & Opcodes.ACC_NATIVE) == Opcodes.ACC_NATIVE) { accessBuilder.append("native "); } if ((modifiers & Opcodes.ACC_TRANSIENT) == Opcodes.ACC_TRANSIENT) { accessBuilder.append("transient "); } if ((modifiers & Opcodes.ACC_VOLATILE) == Opcodes.ACC_VOLATILE) { accessBuilder.append("volatile "); } if ((modifiers & Opcodes.ACC_STRICT) == Opcodes.ACC_STRICT) { accessBuilder.append("strictfp "); } return accessBuilder.toString().trim(); }
From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java
License:Apache License
@Test public void protectedAccess() { assertEquals("protected", AsmUtils.modifiersToString(Opcodes.ACC_PROTECTED)); }
From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java
License:Apache License
@Test public void classAccessOrdering() { assertEquals("public protected private abstract static final strictfp", AsmUtils.modifiersToString(Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_STRICT)); }
From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java
License:Apache License
@Test public void fieldAccessOrdering() { assertEquals("public protected private static final transient volatile", AsmUtils.modifiersToString(Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_VOLATILE)); }
From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java
License:Apache License
@Test public void methodAccessOrdering() { assertEquals("public protected private abstract static final synchronized native strictfp", AsmUtils.modifiersToString(Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT)); }
From source file:org.springsource.loaded.test.infra.ClassPrinter.java
License:Apache License
private String toAccessForClass(int flags) { StringBuilder sb = new StringBuilder(); if ((flags & Opcodes.ACC_PUBLIC) != 0) { sb.append("public "); }/*w w w. java2 s . c o m*/ if ((flags & Opcodes.ACC_PRIVATE) != 0) { sb.append("private "); } if ((flags & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected "); } if ((flags & Opcodes.ACC_STATIC) != 0) { sb.append("static "); } if ((flags & Opcodes.ACC_FINAL) != 0) { sb.append("final "); } if ((flags & Opcodes.ACC_SYNCHRONIZED) != 0) { sb.append("synchronized "); } if ((flags & Opcodes.ACC_BRIDGE) != 0) { sb.append("bridge "); } if ((flags & Opcodes.ACC_VARARGS) != 0) { sb.append("varargs "); } if ((flags & Opcodes.ACC_NATIVE) != 0) { sb.append("native "); } if ((flags & Opcodes.ACC_ABSTRACT) != 0) { sb.append("abstract "); } if ((flags & Opcodes.ACC_SYNTHETIC) != 0) { sb.append("synthetic "); } if ((flags & Opcodes.ACC_DEPRECATED) != 0) { sb.append("deprecated "); } if ((flags & Opcodes.ACC_INTERFACE) != 0) { sb.append("interface "); } return sb.toString().trim(); }
From source file:org.springsource.loaded.test.infra.ClassPrinter.java
License:Apache License
public static String toAccessForMember(int flags) { StringBuilder sb = new StringBuilder(); if ((flags & Opcodes.ACC_PUBLIC) != 0) { sb.append("public "); }//from w w w. j a va 2 s . c o m if ((flags & Opcodes.ACC_PRIVATE) != 0) { sb.append("private "); } if ((flags & Opcodes.ACC_STATIC) != 0) { sb.append("static "); } if ((flags & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected "); } if ((flags & Opcodes.ACC_FINAL) != 0) { sb.append("final "); } if ((flags & Opcodes.ACC_SUPER) != 0) { sb.append("super "); } if ((flags & Opcodes.ACC_INTERFACE) != 0) { sb.append("interface "); } if ((flags & Opcodes.ACC_ABSTRACT) != 0) { sb.append("abstract "); } if ((flags & Opcodes.ACC_SYNTHETIC) != 0) { sb.append("synthetic "); } if ((flags & Opcodes.ACC_ANNOTATION) != 0) { sb.append("annotation "); } if ((flags & Opcodes.ACC_ENUM) != 0) { sb.append("enum "); } if ((flags & Opcodes.ACC_DEPRECATED) != 0) { sb.append("deprecated "); } return sb.toString().trim(); }