当前位置: 首页>>代码示例>>Java>>正文


Java Modifier.VOLATILE属性代码示例

本文整理汇总了Java中java.lang.reflect.Modifier.VOLATILE属性的典型用法代码示例。如果您正苦于以下问题:Java Modifier.VOLATILE属性的具体用法?Java Modifier.VOLATILE怎么用?Java Modifier.VOLATILE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.lang.reflect.Modifier的用法示例。


在下文中一共展示了Modifier.VOLATILE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

public static void main(String [] argv) {
    int allMods = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
        Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
        Modifier.TRANSIENT | Modifier.VOLATILE | Modifier.SYNCHRONIZED |
        Modifier.NATIVE | Modifier.STRICT | Modifier.INTERFACE;

    String allModsString = "public protected private abstract static " +
        "final transient volatile synchronized native strictfp interface";

    /* zero should have an empty string */
    testString(0, "");

    /* test to make sure all modifiers print out in the proper order */
    testString(allMods, allModsString);

    /* verify no extraneous modifiers are printed */
    testString(~0, allModsString);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:toStringTest.java

示例2: retreiveCodeData

/**
 * Writes edited code back to the CustomCodeData structure.
 */
CustomCodeData retreiveCodeData() {
    retreiveCodeData(CodeCategory.CREATE_AND_INIT);
    retreiveCodeData(CodeCategory.DECLARATION);

    VariableDeclaration decl = codeData.getDeclarationData();
    boolean local = variableValues[variableCombo.getSelectedIndex()];
    int modifiers;
    if (local != decl.local) {
        modifiers = local ? lastLocalModifiers : lastFieldModifiers;
        if (finalCheckBox.isSelected()) // only final makes sense for both local and field scope
            modifiers |= Modifier.FINAL;
        else
            modifiers &= ~Modifier.FINAL;
    }
    else {
        modifiers = accessValues[accessCombo.getSelectedIndex()];
        if (staticCheckBox.isSelected())
            modifiers |= Modifier.STATIC;
        if (finalCheckBox.isSelected())
            modifiers |= Modifier.FINAL;
        if (transientCheckBox.isSelected())
            modifiers |= Modifier.TRANSIENT;
        if (volatileCheckBox.isSelected())
            modifiers |= Modifier.VOLATILE;
        if (local)
            modifiers &= ~(Modifier.STATIC | Modifier.TRANSIENT | Modifier.VOLATILE);
    }
    decl.local = local;
    decl.modifiers = modifiers;

    return codeData;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:CustomCodeView.java

示例3: translateModifiers

/**
 * Convert modifier bits from private coding used by
 * the compiler to that of java.lang.reflect.Modifier.
 */
static int translateModifiers(long flags) {
    int result = 0;
    if ((flags & Flags.ABSTRACT) != 0)
        result |= Modifier.ABSTRACT;
    if ((flags & Flags.FINAL) != 0)
        result |= Modifier.FINAL;
    if ((flags & Flags.INTERFACE) != 0)
        result |= Modifier.INTERFACE;
    if ((flags & Flags.NATIVE) != 0)
        result |= Modifier.NATIVE;
    if ((flags & Flags.PRIVATE) != 0)
        result |= Modifier.PRIVATE;
    if ((flags & Flags.PROTECTED) != 0)
        result |= Modifier.PROTECTED;
    if ((flags & Flags.PUBLIC) != 0)
        result |= Modifier.PUBLIC;
    if ((flags & Flags.STATIC) != 0)
        result |= Modifier.STATIC;
    if ((flags & Flags.SYNCHRONIZED) != 0)
        result |= Modifier.SYNCHRONIZED;
    if ((flags & Flags.TRANSIENT) != 0)
        result |= Modifier.TRANSIENT;
    if ((flags & Flags.VOLATILE) != 0)
        result |= Modifier.VOLATILE;
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:DocEnv.java

示例4: computeDefaultSUID

/**
 * 计算默认的 serialVersionUID
 *
 * @see java.io.ObjectStreamClass#lookup(Class)
 * @see java.io.ObjectStreamClass#computeDefaultSUID(Class)
 */
public static long computeDefaultSUID(String className, List<Field> fields) {
    try {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        DataOutputStream dout = new DataOutputStream(bout);

        // simple class name
        dout.writeUTF(className);
        int classMods = Modifier.PUBLIC & (Modifier.PUBLIC | Modifier.FINAL | Modifier.INTERFACE | Modifier.ABSTRACT);
        dout.writeInt(classMods);

        // interface name
        dout.writeUTF("java.io.Serializable");

        // fields
        // fields.sort(Comparator.comparing(Field::getField));
        for (Field field : fields) {
            int mods = Modifier.PRIVATE &
                    (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED |
                            Modifier.STATIC | Modifier.FINAL | Modifier.VOLATILE |
                            Modifier.TRANSIENT);
            if (((mods & Modifier.PRIVATE) == 0) ||
                    ((mods & (Modifier.STATIC | Modifier.TRANSIENT)) == 0)) {
                dout.writeUTF(field.getField());
                dout.writeInt(mods);
                dout.writeUTF(field.getFieldType());
            }
        }

        // method ignore
        dout.flush();

        MessageDigest md = MessageDigest.getInstance("SHA");
        byte[] hashBytes = md.digest(bout.toByteArray());
        long hash = 0;
        for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) {
            hash = (hash << 8) | (hashBytes[i] & 0xFF);
        }
        return hash;
    } catch (Exception e) {
        // ignore
    }
    return 1;
}
 
开发者ID:hykes,项目名称:CodeGen,代码行数:49,代码来源:BuilderUtil.java

示例5: getModifiers

public static long getModifiers( PsiModifierList modifierList )
{
  long modifiers = 0;
  if( modifierList.hasExplicitModifier( PsiModifier.ABSTRACT ) )
  {
    modifiers |= Modifier.ABSTRACT;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.DEFAULT ) )
  {
    modifiers |= 0x80000000000L; //Flags.DEFAULT;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.FINAL ) )
  {
    modifiers |= Modifier.FINAL;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.PRIVATE ) )
  {
    modifiers |= Modifier.PRIVATE;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.PROTECTED ) )
  {
    modifiers |= Modifier.PROTECTED;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.PUBLIC ) )
  {
    modifiers |= Modifier.PUBLIC;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.STATIC ) )
  {
    modifiers |= Modifier.STATIC;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.SYNCHRONIZED ) )
  {
    modifiers |= Modifier.SYNCHRONIZED;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.TRANSIENT ) )
  {
    modifiers |= Modifier.TRANSIENT;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.VOLATILE ) )
  {
    modifiers |= Modifier.VOLATILE;
  }
  return modifiers;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:45,代码来源:StubBuilder.java

示例6: modifiersFrom

public static long modifiersFrom( Set<javax.lang.model.element.Modifier> modifiers )
{
  long mods = 0;
  for( javax.lang.model.element.Modifier mod : modifiers )
  {
    switch( mod )
    {
      case PUBLIC:
        mods |= Modifier.PUBLIC;
        break;
      case PROTECTED:
        mods |= Modifier.PROTECTED;
        break;
      case PRIVATE:
        mods |= Modifier.PRIVATE;
        break;
      case ABSTRACT:
        mods |= Modifier.ABSTRACT;
        break;
      case DEFAULT:
        mods |= Flags.DEFAULT;
        break;
      case STATIC:
        mods |= Modifier.STATIC;
        break;
      case FINAL:
        mods |= Modifier.FINAL;
        break;
      case TRANSIENT:
        mods |= Modifier.TRANSIENT;
        break;
      case VOLATILE:
        mods |= Modifier.VOLATILE;
        break;
      case SYNCHRONIZED:
        mods |= Modifier.SYNCHRONIZED;
        break;
      case NATIVE:
        mods |= Modifier.NATIVE;
        break;
      case STRICTFP:
        mods |= Flags.STRICTFP;
        break;
    }
  }
  return mods;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:47,代码来源:SrcAnnotated.java

示例7: renderModifiers

protected String renderModifiers( StringBuilder sb, long modifiers, boolean isDefault, int defModifier )
{
  if( isDefault )
  {
    sb.append( "default " );
  }

  if( (modifiers & Modifier.PUBLIC) != 0 )
  {
    sb.append( "public " );
  }
  else if( (modifiers & Modifier.PROTECTED) != 0 )
  {
    sb.append( "protected " );
  }
  else if( (modifiers & Modifier.PRIVATE) != 0 )
  {
    sb.append( "private " );
  }
  else if( defModifier != 0 )
  {
    renderModifiers( sb, defModifier, false, 0 );
  }

  // Canonical order
  if( (modifiers & Modifier.ABSTRACT) != 0 )
  {
    sb.append( "abstract " );
  }
  if( (modifiers & Modifier.STATIC) != 0 )
  {
    sb.append( "static " );
  }
  if( (modifiers & Modifier.FINAL) != 0 )
  {
    sb.append( "final " );
  }
  if( (modifiers & Modifier.TRANSIENT) != 0 )
  {
    sb.append( "transient " );
  }
  if( (modifiers & Modifier.VOLATILE) != 0 )
  {
    sb.append( "volatile " );
  }
  if( (modifiers & Modifier.SYNCHRONIZED) != 0 )
  {
    sb.append( "synchronized " );
  }
  if( (modifiers & Modifier.INTERFACE) != 0 )
  {
    sb.append( "interface " );
  }

  return "";
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:56,代码来源:SrcAnnotated.java


注:本文中的java.lang.reflect.Modifier.VOLATILE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。