當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。