List of usage examples for org.objectweb.asm Opcodes ACC_VOLATILE
int ACC_VOLATILE
To view the source code for org.objectweb.asm Opcodes ACC_VOLATILE.
Click Source Link
From source file:org.osjava.jardiff.ToolsTest.java
License:Apache License
@Test public void isFieldAccessChange() { // A field can't become final. assertTrue(Tools.isFieldAccessChange(0, Opcodes.ACC_FINAL)); assertTrue(Tools.isFieldAccessChange(0, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL)); // ... but can become non-final. assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_FINAL, 0)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_FINAL + Opcodes.ACC_PUBLIC, Opcodes.ACC_PUBLIC)); // A field can become more accessible assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PROTECTED, Opcodes.ACC_PUBLIC)); assertFalse(Tools.isFieldAccessChange(0, Opcodes.ACC_PUBLIC)); assertFalse(Tools.isFieldAccessChange(0, Opcodes.ACC_PROTECTED)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PRIVATE, Opcodes.ACC_PUBLIC)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PRIVATE, Opcodes.ACC_PROTECTED)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PRIVATE, 0)); // ...but can't become less accessible assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_FINAL + Opcodes.ACC_PUBLIC, 0)); assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PROTECTED)); assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PRIVATE)); assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PROTECTED, 0)); assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PROTECTED, Opcodes.ACC_PRIVATE)); assertTrue(Tools.isFieldAccessChange(0, Opcodes.ACC_PRIVATE)); // A field can't change static assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_STATIC, 0)); assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC, Opcodes.ACC_PUBLIC)); // A field can't change volatile assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_VOLATILE, 0)); assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_VOLATILE + Opcodes.ACC_PUBLIC, Opcodes.ACC_PUBLIC)); // A field can change transient assertFalse(Tools.isFieldAccessChange(0, Opcodes.ACC_TRANSIENT)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PUBLIC + Opcodes.ACC_TRANSIENT)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_TRANSIENT, 0)); assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PUBLIC + Opcodes.ACC_TRANSIENT, Opcodes.ACC_PUBLIC)); }
From source file:org.rascalmpl.library.lang.java.m3.internal.JarConverter.java
License:Open Source License
private IConstructor mapFieldAccesCode(int code, int where) { // Check the original M3 implementation for possible IConstructor types. switch (code) { case Opcodes.ACC_PUBLIC: return constructModifierNode("public"); case Opcodes.ACC_PRIVATE: return constructModifierNode("private"); case Opcodes.ACC_PROTECTED: return constructModifierNode("protected"); case Opcodes.ACC_STATIC: return constructModifierNode("static"); case Opcodes.ACC_FINAL: return constructModifierNode("final"); case Opcodes.ACC_SYNCHRONIZED: if (where == CLASSE) return null; return constructModifierNode("synchronized"); case Opcodes.ACC_ABSTRACT: return constructModifierNode("abstract"); case Opcodes.ACC_VOLATILE: return constructModifierNode("volatile"); case Opcodes.ACC_TRANSIENT: return constructModifierNode("transient"); case Opcodes.ACC_NATIVE: return constructModifierNode("native"); // TODO: GIT PULL/MERGE ORIGINAL RASCAL VERSION < 2013-11-30 (Shahin commit) // case Opcodes.ACC_DEPRECATED: // return constructModifierNode("deprecated"); default://from www .j a v a 2 s . com return null; } }
From source file:org.sonar.java.resolve.FlagsTest.java
License:Open Source License
/** * Flags can be easily loaded from class-files into symbols. *//* w ww. ja v a 2 s . co m*/ @Test public void flags_match_asm_opcodes() { assertThat(Flags.PUBLIC).isEqualTo(Opcodes.ACC_PUBLIC); assertThat(Flags.PRIVATE).isEqualTo(Opcodes.ACC_PRIVATE); assertThat(Flags.PROTECTED).isEqualTo(Opcodes.ACC_PROTECTED); assertThat(Flags.STATIC).isEqualTo(Opcodes.ACC_STATIC); assertThat(Flags.FINAL).isEqualTo(Opcodes.ACC_FINAL); assertThat(Flags.SYNCHRONIZED).isEqualTo(Opcodes.ACC_SYNCHRONIZED); assertThat(Flags.VOLATILE).isEqualTo(Opcodes.ACC_VOLATILE); assertThat(Flags.TRANSIENT).isEqualTo(Opcodes.ACC_TRANSIENT); assertThat(Flags.NATIVE).isEqualTo(Opcodes.ACC_NATIVE); assertThat(Flags.INTERFACE).isEqualTo(Opcodes.ACC_INTERFACE); assertThat(Flags.ABSTRACT).isEqualTo(Opcodes.ACC_ABSTRACT); assertThat(Flags.STRICTFP).isEqualTo(Opcodes.ACC_STRICT); assertThat(Flags.SYNTHETIC).isEqualTo(Opcodes.ACC_SYNTHETIC); assertThat(Flags.ANNOTATION).isEqualTo(Opcodes.ACC_ANNOTATION); assertThat(Flags.ENUM).isEqualTo(Opcodes.ACC_ENUM); }
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.springframework.migrationanalyzer.contributions.bytecode.AsmUtils.java
License:Apache License
/** * Converts the given bitwise ORed <code>modifiers</code> into a {@link String}. * /* ww w . j a v a 2s .c om*/ * <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 volatileAccess() { assertEquals("volatile", AsmUtils.modifiersToString(Opcodes.ACC_VOLATILE)); }
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.teavm.parsing.Parser.java
License:Apache License
public static void parseModifiers(int access, ElementHolder member) { if ((access & Opcodes.ACC_PRIVATE) != 0) { member.setLevel(AccessLevel.PRIVATE); } else if ((access & Opcodes.ACC_PROTECTED) != 0) { member.setLevel(AccessLevel.PROTECTED); } else if ((access & Opcodes.ACC_PUBLIC) != 0) { member.setLevel(AccessLevel.PUBLIC); }/*from w w w .jav a2s .c om*/ if ((access & Opcodes.ACC_ABSTRACT) != 0) { member.getModifiers().add(ElementModifier.ABSTRACT); } if ((access & Opcodes.ACC_ANNOTATION) != 0) { member.getModifiers().add(ElementModifier.ANNOTATION); } if ((access & Opcodes.ACC_BRIDGE) != 0) { member.getModifiers().add(ElementModifier.BRIDGE); } if ((access & Opcodes.ACC_DEPRECATED) != 0) { member.getModifiers().add(ElementModifier.DEPRECATED); } if ((access & Opcodes.ACC_ENUM) != 0) { member.getModifiers().add(ElementModifier.ENUM); } if ((access & Opcodes.ACC_FINAL) != 0) { member.getModifiers().add(ElementModifier.FINAL); } if ((access & Opcodes.ACC_INTERFACE) != 0) { member.getModifiers().add(ElementModifier.INTERFACE); } if ((access & Opcodes.ACC_NATIVE) != 0) { member.getModifiers().add(ElementModifier.NATIVE); } if ((access & Opcodes.ACC_STATIC) != 0) { member.getModifiers().add(ElementModifier.STATIC); } if ((access & Opcodes.ACC_STRICT) != 0) { member.getModifiers().add(ElementModifier.STRICT); } if ((access & Opcodes.ACC_SUPER) != 0) { member.getModifiers().add(ElementModifier.SUPER); } if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { member.getModifiers().add(ElementModifier.SYNCHRONIZED); } if ((access & Opcodes.ACC_SYNTHETIC) != 0) { member.getModifiers().add(ElementModifier.SYNTHETIC); } if ((access & Opcodes.ACC_TRANSIENT) != 0) { member.getModifiers().add(ElementModifier.TRANSIENT); } if ((access & Opcodes.ACC_VARARGS) != 0) { member.getModifiers().add(ElementModifier.VARARGS); } if ((access & Opcodes.ACC_VOLATILE) != 0) { member.getModifiers().add(ElementModifier.VOLATILE); } }
From source file:the.bytecode.club.bytecodeviewer.decompilers.bytecode.FieldNodeDecompiler.java
License:Open Source License
private static String getAccessString(int access) { List<String> tokens = new ArrayList<String>(); if ((access & Opcodes.ACC_PUBLIC) != 0) tokens.add("public"); if ((access & Opcodes.ACC_PRIVATE) != 0) tokens.add("private"); if ((access & Opcodes.ACC_PROTECTED) != 0) tokens.add("protected"); if ((access & Opcodes.ACC_SYNTHETIC) != 0) tokens.add("synthetic"); if ((access & Opcodes.ACC_STATIC) != 0) tokens.add("static"); if ((access & Opcodes.ACC_FINAL) != 0) tokens.add("final"); if ((access & Opcodes.ACC_TRANSIENT) != 0) tokens.add("transient"); if ((access & Opcodes.ACC_VOLATILE) != 0) tokens.add("volatile"); if (tokens.size() == 0) return ""; // hackery delimeters StringBuilder sb = new StringBuilder(tokens.get(0)); for (int i = 1; i < tokens.size(); i++) { sb.append(" "); sb.append(tokens.get(i));/*from ww w . ja v a 2 s. c o m*/ } return sb.toString(); }