com.sun.tools.javac.code.SymbolMetadata Java Examples

The following examples show how to use com.sun.tools.javac.code.SymbolMetadata. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManTypes.java    From manifold with Apache License 2.0 6 votes vote down vote up
private java.util.List<TypeAnnotationPosition> findSelfAnnotationLocation( Symbol sym )
{
  if( sym == null )
  {
    return null;
  }

  SymbolMetadata metadata = sym.getMetadata();
  if( metadata == null || metadata.isTypesEmpty() )
  {
    return null;
  }

  List<Attribute.TypeCompound> typeAttributes = metadata.getTypeAttributes();
  if( typeAttributes.isEmpty() )
  {
    return null;
  }

  return typeAttributes.stream()
    .filter( attr -> attr.type.toString().equals( SELF_TYPE_NAME ) )
    .map( Attribute.TypeCompound::getPosition )
    .collect( Collectors.toList() );
}
 
Example #2
Source File: DPrinter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #3
Source File: DPrinter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #4
Source File: DPrinter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #5
Source File: DPrinter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #6
Source File: SrcClassUtil.java    From manifold with Apache License 2.0 5 votes vote down vote up
private SrcType makeSrcType( Type type, Symbol symbol, TargetType targetType, int index )
{
  SrcType srcType;
  List<Attribute.TypeCompound> annotationMirrors = type.getAnnotationMirrors();
  if( annotationMirrors != null && !annotationMirrors.isEmpty() )
  {
    String unannotatedType = isJava8()
                             ? ReflectUtil.method( type, "unannotatedType" ).invoke().toString()
                             : ReflectUtil.method( type, "cloneWithMetadata", ReflectUtil.type( "com.sun.tools.javac.code.TypeMetadata" ) )
                               .invoke( ReflectUtil.field( "com.sun.tools.javac.code.TypeMetadata", "EMPTY" ).getStatic() ).toString();
    srcType = new SrcType( unannotatedType );
  }
  else
  {
    srcType = new SrcType( typeNoAnnotations( type ) );
  }
  SymbolMetadata metadata = symbol.getMetadata();
  if( metadata == null || metadata.isTypesEmpty() )
  {
    return srcType;
  }
  List<Attribute.TypeCompound> typeAttributes = metadata.getTypeAttributes();
  if( typeAttributes.isEmpty() )
  {
    return null;
  }

  java.util.List<Attribute.TypeCompound> targetedTypeAttrs = typeAttributes.stream()
    .filter( attr -> attr.getPosition().type == targetType && isTargetIndex( targetType, attr, index ) )
    .collect( Collectors.toList() );

  annotateType( srcType, targetedTypeAttrs );
  return srcType;
}
 
Example #7
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("WeakerAccess")
public static boolean isJailbreakSymbol( Symbol sym )
{
  if( sym == null )
  {
    return false;
  }

  SymbolMetadata metadata = sym.getMetadata();
  if( metadata == null || (metadata.isTypesEmpty() && metadata.isEmpty()) )
  {
    return false;
  }

  List<Attribute.TypeCompound> typeAttributes = metadata.getTypeAttributes();
  if( !typeAttributes.isEmpty() )
  {
    return typeAttributes.stream()
      .anyMatch( attr -> attr.type.toString().equals( Jailbreak.class.getTypeName() ) );
  }

  List<Attribute.Compound> attributes = metadata.getDeclarationAttributes();
  if( !attributes.isEmpty() )
  {
    return attributes.stream()
      .anyMatch( attr -> attr.type.toString().equals( Jailbreak.class.getTypeName() ) );
  }
  return false;
}
 
Example #8
Source File: DPrinter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #9
Source File: DPrinter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #10
Source File: DPrinter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #11
Source File: DPrinter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
        printNull(label);
    } else {
        // no SUMMARY format currently available to use

        // use reflection to get at private fields
        Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
        Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
        Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
        Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

        if (!showEmptyItems) {
            if (attributes instanceof List && ((List) attributes).isEmpty()
                    && attributes != DECL_NOT_STARTED
                    && attributes != DECL_IN_PROGRESS
                    && type_attributes instanceof List && ((List) type_attributes).isEmpty())
                return;
        }

        printString(label, hashString(annotations));

        indent(+1);
        if (attributes == DECL_NOT_STARTED)
            printString("attributes", "DECL_NOT_STARTED");
        else if (attributes == DECL_IN_PROGRESS)
            printString("attributes", "DECL_IN_PROGRESS");
        else if (attributes instanceof List)
            printList("attributes", (List) attributes);
        else
            printObject("attributes", attributes, Details.SUMMARY);

        if (attributes instanceof List)
            printList("type_attributes", (List) type_attributes);
        else
            printObject("type_attributes", type_attributes, Details.SUMMARY);
        indent(-1);
    }
}
 
Example #12
Source File: DPrinter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #13
Source File: DPrinter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #14
Source File: DPrinter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #15
Source File: DPrinter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #16
Source File: DPrinter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #17
Source File: DPrinter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #18
Source File: DPrinter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}
 
Example #19
Source File: DPrinter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void printAnnotations(String label, SymbolMetadata annotations) {
    printAnnotations(label, annotations, Details.FULL);
}