List of usage examples for org.objectweb.asm Opcodes ACC_TRANSIENT
int ACC_TRANSIENT
To view the source code for org.objectweb.asm Opcodes ACC_TRANSIENT.
Click Source Link
From source file:org.openspotlight.bundle.language.java.resolver.JavaGraphNodeSupport.java
License:Open Source License
/** * Insert field data./*from w ww . j a v a 2 s.c o m*/ * * @param field the field * @param fieldType the field type * @param access the access * @param isArray the is array * @param dimension the dimension * @throws Exception the exception */ private void insertFieldData(final JavaDataField field, final JavaType fieldType, final int access, final boolean isArray, final int dimension) throws Exception { final DataType fieldTypeLink = session.addLink(DataType.class, field, fieldType, false); fieldTypeLink.setArray(isArray); fieldTypeLink.setArrayDimension(dimension); final boolean isFieldPublic = (access & Opcodes.ACC_PUBLIC) != 0; final boolean isFieldPrivate = (access & Opcodes.ACC_PRIVATE) != 0; final boolean isFieldStatic = (access & Opcodes.ACC_STATIC) != 0; final boolean isFieldFinal = (access & Opcodes.ACC_FINAL) != 0; final boolean isFieldProtected = (access & Opcodes.ACC_PROTECTED) != 0; final boolean isFieldTransient = (access & Opcodes.ACC_TRANSIENT) != 0; final boolean isFieldVolatile = (access & Opcodes.ACC_VOLATILE) != 0; field.setPublic(isFieldPublic); field.setPrivate(isFieldPrivate); field.setStatic(isFieldStatic); field.setFinal(isFieldFinal); field.setProtected(isFieldProtected); field.setTransient(isFieldTransient); field.setVolatile(isFieldVolatile); }
From source file:org.osjava.jardiff.Tools.java
License:Apache License
/** * Returns whether a field's newAccess is incompatible with oldAccess * following <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html">Java Language Specification, Java SE 7 Edition</a>: * <ul>//w ww. ja v a2s .c o m * <li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.9">13.4.7 Access to Members and Constructors</a><ul> * <li>Changing the declared access of a member or constructor to permit less access * <b>may break compatibility</b> with pre-existing binaries, causing a linkage error to be thrown when these binaries are resolved. * </li> * <li>The binary format is defined so that changing a member or constructor to be more accessible does not cause a * linkage error when a subclass (already) defines a method to have less access. * </li> * </ul></li> * <li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.9">13.4.9 final Fields and Constants</a><ul> * <li>If a field that was not declared final is changed to be declared final, * then it <b>can break compatibility</b> with pre-existing binaries that attempt to assign new values to the field.</li> * <li>Deleting the keyword final or changing the value to which a <i>non-final</i> field is initialized * <b>does not break compatibility</b> with existing binaries.</li> * <li>If a field is a constant variable (4.12.4), * then deleting the keyword final or changing its value * will <i>not break compatibility</i> with pre-existing binaries by causing them not to run, * but they will not see any new value for the usage of the field unless they are recompiled. * This is true even if the usage itself is not a compile-time constant expression (15.28). * Such changes <b>break functional backward compatibility</b>!</li> * </ul></li> * <li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.10">13.4.10 static Fields</a><ul> * <li>If a field that is not declared private was not declared static * and is changed to be declared static, or vice versa, * then a linkage error, specifically an IncompatibleClassChangeError, * will result if the field is used by a pre-existing binary which expected a field of the other kind. * Such changes <b>break backward compatibility</b>!</li> * </ul></li> * <li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.11">13.4.11. transient Fields </a><ul> * <li>Adding or deleting a transient modifier of a field * <b>does not break compatibility</b> with pre-existing binaries.</li> * </ul></li> * <li><a href="http://www.wsu.edu/UNIX_Systems/java/langspec-1.0/13.doc.html#45194">13.4.11 volatile Fields (JLS 1.0)</a><ul> * <li>If a field that is not declared private was not declared volatile * and is changed to be declared volatile, or vice versa, then a linkage time error, * specifically an IncompatibleClassChangeError, may result if the field is used * by a preexisting binary that expected a field of the opposite volatility. * Such changes <b>break backward compatibility</b>!</li> * </ul></li> * </ul> * * @param oldAccess * @param newAccess * @return */ public static boolean isFieldAccessChange(final int oldAccess, final int newAccess) { if (isAccessIncompatible(oldAccess, newAccess)) { return true; // 13.4.7 } if (not(oldAccess, Opcodes.ACC_FINAL) && has(newAccess, Opcodes.ACC_FINAL)) { return true; // 13.4.9 #1 } else { final int compatibleChanges = Opcodes.ACC_FINAL | // 13.4.9 #2 Opcodes.ACC_TRANSIENT; // 13.4.11 #1 final int accessPermissions = Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE; final int oldAccess2 = oldAccess & ~compatibleChanges & ~accessPermissions; final int newAccess2 = newAccess & ~compatibleChanges & ~accessPermissions; return oldAccess2 != newAccess2; } }
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:/*w w w.j a v a 2s.c om*/ 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 . j a 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.springframework.migrationanalyzer.contributions.bytecode.AsmUtils.java
License:Apache License
/** * Converts the given bitwise ORed <code>modifiers</code> into a {@link String}. * //w w w . ja v a 2s .c o 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 transientAccess() { assertEquals("transient", AsmUtils.modifiersToString(Opcodes.ACC_TRANSIENT)); }
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); }/* w w w.j a va2 s .com*/ 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:org.wavescale.hotload.transformer.api.VarArgsHelperMethod.java
License:Open Source License
public VarArgsHelperMethod(Class clazz, String methodName) { super(Opcodes.ASM5, Opcodes.ACC_PUBLIC | Opcodes.ACC_TRANSIENT | Opcodes.ACC_VARARGS, methodName, Constants.VARARGS_METHOD_CALL_DESCRIPTOR, null, null); this.clazz = clazz; addEmptyContent();// www .j a va2s . c om }