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


Java Modifier.SYNCHRONIZED属性代码示例

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


在下文中一共展示了Modifier.SYNCHRONIZED属性的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: 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

示例3: main

public static void main(String[] args) throws Exception {
    /* We are not testing for the ACC_SUPER bug, so strip we strip
     * synchorized. */

    int m = 0;

    m = Inner.class.getModifiers() & (~Modifier.SYNCHRONIZED);
    if (m != Modifier.PRIVATE)
        throw new Exception("Access bits for innerclass not from " +
                            "InnerClasses attribute");

    m = Protected.class.getModifiers() & (~Modifier.SYNCHRONIZED);
    if (m != Modifier.PROTECTED)
        throw new Exception("Protected inner class wronged modifiers");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:ForInnerClass.java

示例4: 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

示例5: 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

示例6: 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

示例7: modifierString

/**
 * Return a string describing the access modifier flags.
 * Don't include native or synchronized.
 *
 * The modifier names are returned in canonical order, as
 * specified by <em>The Java Language Specification</em>.
 */
protected String modifierString(MemberDoc member) {
    int ms = member.modifierSpecifier();
    int no = Modifier.NATIVE | Modifier.SYNCHRONIZED;
return Modifier.toString(ms & ~no);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:AbstractMemberWriter.java


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