idx
int64 0
41.2k
| question
stringlengths 74
4.21k
| target
stringlengths 5
888
|
---|---|---|
1,000 |
void showClass ( String className ) { PrintWriter pw = log . getWriter ( WriterKind . NOTICE ) ; pw . println ( "javac: show class: " + className ) ; URL url = getClass ( ) . getResource ( '/' + className . replace ( '.' , '/' ) + ".class" ) ; if ( url != null ) { pw . println ( " " + url ) ; } try ( InputStream in = getClass ( ) . getResourceAsStream ( '/' + className . replace ( '.' , '/' ) + ".class" ) ) { final String algorithm = "MD5" ; byte [ ] digest ; MessageDigest md = MessageDigest . getInstance ( algorithm ) ; try ( DigestInputStream din = new DigestInputStream ( in , md ) ) { byte [ ] buf = new byte [ 8192 ] ; int n ; do { n = din . read ( buf ) ; } while ( n > 0 ) ; digest = md . digest ( ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( byte b : digest ) sb . append ( String . format ( "%02x" , b ) ) ; pw . println ( " " + algorithm + " checksum: " + sb ) ; } catch ( NoSuchAlgorithmException | IOException e ) { pw . println ( " cannot compute digest: " + e ) ; } }
|
Display the location and checksum of a class .
|
1,001 |
protected void addPackageList ( Content contentTree ) throws IOException { Content caption = getTableCaption ( configuration . getResource ( "doclet.ClassUse_Packages.that.use.0" , getLink ( new LinkInfoImpl ( configuration , LinkInfoImpl . Kind . CLASS_USE_HEADER , classdoc ) ) ) ) ; Content table = ( configuration . isOutputHtml5 ( ) ) ? HtmlTree . TABLE ( HtmlStyle . useSummary , caption ) : HtmlTree . TABLE ( HtmlStyle . useSummary , useTableSummary , caption ) ; table . addContent ( getSummaryTableHeader ( packageTableHeader , "col" ) ) ; Content tbody = new HtmlTree ( HtmlTag . TBODY ) ; Iterator < PackageDoc > it = pkgSet . iterator ( ) ; for ( int i = 0 ; it . hasNext ( ) ; i ++ ) { PackageDoc pkg = it . next ( ) ; HtmlTree tr = new HtmlTree ( HtmlTag . TR ) ; if ( i % 2 == 0 ) { tr . addStyle ( HtmlStyle . altColor ) ; } else { tr . addStyle ( HtmlStyle . rowColor ) ; } addPackageUse ( pkg , tr ) ; tbody . addContent ( tr ) ; } table . addContent ( tbody ) ; Content li = HtmlTree . LI ( HtmlStyle . blockList , table ) ; contentTree . addContent ( li ) ; }
|
Add the packages list that use the given class .
|
1,002 |
protected void addPackageAnnotationList ( Content contentTree ) throws IOException { if ( ( ! classdoc . isAnnotationType ( ) ) || pkgToPackageAnnotations == null || pkgToPackageAnnotations . isEmpty ( ) ) { return ; } Content caption = getTableCaption ( configuration . getResource ( "doclet.ClassUse_PackageAnnotation" , getLink ( new LinkInfoImpl ( configuration , LinkInfoImpl . Kind . CLASS_USE_HEADER , classdoc ) ) ) ) ; Content table = ( configuration . isOutputHtml5 ( ) ) ? HtmlTree . TABLE ( HtmlStyle . useSummary , caption ) : HtmlTree . TABLE ( HtmlStyle . useSummary , useTableSummary , caption ) ; table . addContent ( getSummaryTableHeader ( packageTableHeader , "col" ) ) ; Content tbody = new HtmlTree ( HtmlTag . TBODY ) ; Iterator < PackageDoc > it = pkgToPackageAnnotations . iterator ( ) ; for ( int i = 0 ; it . hasNext ( ) ; i ++ ) { PackageDoc pkg = it . next ( ) ; HtmlTree tr = new HtmlTree ( HtmlTag . TR ) ; if ( i % 2 == 0 ) { tr . addStyle ( HtmlStyle . altColor ) ; } else { tr . addStyle ( HtmlStyle . rowColor ) ; } Content tdFirst = HtmlTree . TD ( HtmlStyle . colFirst , getPackageLink ( pkg , new StringContent ( pkg . name ( ) ) ) ) ; tr . addContent ( tdFirst ) ; HtmlTree tdLast = new HtmlTree ( HtmlTag . TD ) ; tdLast . addStyle ( HtmlStyle . colLast ) ; addSummaryComment ( pkg , tdLast ) ; tr . addContent ( tdLast ) ; tbody . addContent ( tr ) ; } table . addContent ( tbody ) ; Content li = HtmlTree . LI ( HtmlStyle . blockList , table ) ; contentTree . addContent ( li ) ; }
|
Add the package annotation list .
|
1,003 |
protected HtmlTree getClassUseHeader ( ) { String cltype = configuration . getText ( classdoc . isInterface ( ) ? "doclet.Interface" : "doclet.Class" ) ; String clname = classdoc . qualifiedName ( ) ; String title = configuration . getText ( "doclet.Window_ClassUse_Header" , cltype , clname ) ; HtmlTree bodyTree = getBody ( true , getWindowTitle ( title ) ) ; HtmlTree htmlTree = ( configuration . allowTag ( HtmlTag . HEADER ) ) ? HtmlTree . HEADER ( ) : bodyTree ; addTop ( htmlTree ) ; addNavLinks ( true , htmlTree ) ; if ( configuration . allowTag ( HtmlTag . HEADER ) ) { bodyTree . addContent ( htmlTree ) ; } ContentBuilder headContent = new ContentBuilder ( ) ; headContent . addContent ( getResource ( "doclet.ClassUse_Title" , cltype ) ) ; headContent . addContent ( new HtmlTree ( HtmlTag . BR ) ) ; headContent . addContent ( clname ) ; Content heading = HtmlTree . HEADING ( HtmlConstants . CLASS_PAGE_HEADING , true , HtmlStyle . title , headContent ) ; Content div = HtmlTree . DIV ( HtmlStyle . header , heading ) ; if ( configuration . allowTag ( HtmlTag . MAIN ) ) { mainTree . addContent ( div ) ; } else { bodyTree . addContent ( div ) ; } return bodyTree ; }
|
Get the header for the class use Listing .
|
1,004 |
protected Content getNavLinkPackage ( ) { Content linkContent = getHyperLink ( DocPath . parent . resolve ( DocPaths . PACKAGE_SUMMARY ) , packageLabel ) ; Content li = HtmlTree . LI ( linkContent ) ; return li ; }
|
Get this package link .
|
1,005 |
protected Content getNavLinkClass ( ) { Content linkContent = getLink ( new LinkInfoImpl ( configuration , LinkInfoImpl . Kind . CLASS_USE_HEADER , classdoc ) . label ( configuration . getText ( "doclet.Class" ) ) ) ; Content li = HtmlTree . LI ( linkContent ) ; return li ; }
|
Get class page link .
|
1,006 |
public static ClassBuilder getInstance ( Context context , TypeElement typeElement , ClassWriter writer ) { return new ClassBuilder ( context , typeElement , writer ) ; }
|
Constructs a new ClassBuilder .
|
1,007 |
private void copyDocFiles ( ) throws DocFileIOException { PackageElement containingPackage = utils . containingPackage ( typeElement ) ; if ( ( configuration . packages == null || ! configuration . packages . contains ( containingPackage ) ) && ! containingPackagesSeen . contains ( containingPackage ) ) { utils . copyDocFiles ( containingPackage ) ; containingPackagesSeen . add ( containingPackage ) ; } }
|
Copy the doc files .
|
1,008 |
static String parms ( String types ) { int [ ] pos = new int [ ] { 0 } ; StringBuilder sb = new StringBuilder ( ) ; boolean first = true ; String t ; while ( ( t = desc ( types , pos ) ) != null ) { if ( first ) { first = false ; } else { sb . append ( ',' ) ; } sb . append ( t ) ; } return sb . toString ( ) ; }
|
Converts a series of type descriptors into a comma - separated readable string . This is used for the parameter types of a method descriptor .
|
1,009 |
public static String print ( DeprData dd ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( depr ( dd . since , dd . forRemoval ) ) . append ( ' ' ) ; switch ( dd . kind ) { case ANNOTATION_TYPE : sb . append ( "@interface " ) ; sb . append ( unslashify ( dd . typeName ) ) ; break ; case CLASS : sb . append ( "class " ) ; sb . append ( unslashify ( dd . typeName ) ) ; break ; case ENUM : sb . append ( "enum " ) ; sb . append ( unslashify ( dd . typeName ) ) ; break ; case INTERFACE : sb . append ( "interface " ) ; sb . append ( unslashify ( dd . typeName ) ) ; break ; case ENUM_CONSTANT : case FIELD : sb . append ( unslashify ( dd . typeName ) ) . append ( '.' ) . append ( dd . nameSig ) ; break ; case CONSTRUCTOR : Matcher cons = DESC_PAT . matcher ( dd . nameSig ) ; sb . append ( unslashify ( dd . typeName ) ) ; if ( cons . matches ( ) ) { sb . append ( '(' ) . append ( parms ( cons . group ( "args" ) ) ) . append ( ')' ) ; } else { sb . append ( '.' ) . append ( dd . nameSig ) ; } break ; case METHOD : Matcher meth = DESC_PAT . matcher ( dd . nameSig ) ; if ( meth . matches ( ) ) { sb . append ( desc ( meth . group ( "return" ) ) ) . append ( ' ' ) . append ( unslashify ( dd . typeName ) ) . append ( '.' ) . append ( meth . group ( "name" ) ) . append ( '(' ) . append ( parms ( meth . group ( "args" ) ) ) . append ( ')' ) ; } else { sb . append ( unslashify ( dd . typeName ) ) . append ( '.' ) . append ( dd . nameSig ) ; } break ; } return sb . toString ( ) ; }
|
Pretty - prints the data contained in the given DeprData object .
|
1,010 |
String show ( boolean isRetained ) { String cmd = "/set start " + ( isRetained ? "-retain " : "" ) ; if ( isDefault ( ) ) { return cmd + "-default\n" ; } else if ( isEmpty ( ) ) { return cmd + "-none\n" ; } else { return entries . stream ( ) . map ( sue -> sue . name ) . collect ( joining ( " " , cmd , "\n" ) ) ; } }
|
show commands to re - create
|
1,011 |
private static StartupEntry readFile ( String filename , String context , MessageHandler mh ) { if ( filename != null ) { try { byte [ ] encoded = Files . readAllBytes ( toPathResolvingUserHome ( filename ) ) ; return new StartupEntry ( false , filename , new String ( encoded ) , LocalDateTime . now ( ) . format ( DateTimeFormatter . ofLocalizedDateTime ( FormatStyle . MEDIUM ) ) ) ; } catch ( AccessDeniedException e ) { mh . errormsg ( "jshell.err.file.not.accessible" , context , filename , e . getMessage ( ) ) ; } catch ( NoSuchFileException e ) { String resource = getResource ( filename ) ; if ( resource != null ) { return new StartupEntry ( true , filename , resource ) ; } mh . errormsg ( "jshell.err.file.not.found" , context , filename ) ; } catch ( Exception e ) { mh . errormsg ( "jshell.err.file.exception" , context , filename , e ) ; } } else { mh . errormsg ( "jshell.err.file.filename" , context ) ; } return null ; }
|
Read a external file or a resource .
|
1,012 |
public static boolean isConstructor ( JCTree tree ) { if ( tree . hasTag ( METHODDEF ) ) { Name name = ( ( JCMethodDecl ) tree ) . name ; return name == name . table . names . init ; } else { return false ; } }
|
Is tree a constructor declaration?
|
1,013 |
public static boolean hasConstructors ( List < JCTree > trees ) { for ( List < JCTree > l = trees ; l . nonEmpty ( ) ; l = l . tail ) if ( isConstructor ( l . head ) ) return true ; return false ; }
|
Is there a constructor declaration in the given list of trees?
|
1,014 |
public static boolean isSyntheticInit ( JCTree stat ) { if ( stat . hasTag ( EXEC ) ) { JCExpressionStatement exec = ( JCExpressionStatement ) stat ; if ( exec . expr . hasTag ( ASSIGN ) ) { JCAssign assign = ( JCAssign ) exec . expr ; if ( assign . lhs . hasTag ( SELECT ) ) { JCFieldAccess select = ( JCFieldAccess ) assign . lhs ; if ( select . sym != null && ( select . sym . flags ( ) & SYNTHETIC ) != 0 ) { Name selected = name ( select . selected ) ; if ( selected != null && selected == selected . table . names . _this ) return true ; } } } } return false ; }
|
Is statement an initializer for a synthetic field?
|
1,015 |
public static Name calledMethodName ( JCTree tree ) { if ( tree . hasTag ( EXEC ) ) { JCExpressionStatement exec = ( JCExpressionStatement ) tree ; if ( exec . expr . hasTag ( APPLY ) ) { Name mname = TreeInfo . name ( ( ( JCMethodInvocation ) exec . expr ) . meth ) ; return mname ; } } return null ; }
|
If the expression is a method call return the method name null otherwise .
|
1,016 |
public static boolean isSelfCall ( JCTree tree ) { Name name = calledMethodName ( tree ) ; if ( name != null ) { Names names = name . table . names ; return name == names . _this || name == names . _super ; } else { return false ; } }
|
Is this a call to this or super?
|
1,017 |
public static boolean isSuperCall ( JCTree tree ) { Name name = calledMethodName ( tree ) ; if ( name != null ) { Names names = name . table . names ; return name == names . _super ; } else { return false ; } }
|
Is this a call to super?
|
1,018 |
public static JCMethodInvocation firstConstructorCall ( JCTree tree ) { if ( ! tree . hasTag ( METHODDEF ) ) return null ; JCMethodDecl md = ( JCMethodDecl ) tree ; Names names = md . name . table . names ; if ( md . name != names . init ) return null ; if ( md . body == null ) return null ; List < JCStatement > stats = md . body . stats ; while ( stats . nonEmpty ( ) && isSyntheticInit ( stats . head ) ) stats = stats . tail ; if ( stats . isEmpty ( ) ) return null ; if ( ! stats . head . hasTag ( EXEC ) ) return null ; JCExpressionStatement exec = ( JCExpressionStatement ) stats . head ; if ( ! exec . expr . hasTag ( APPLY ) ) return null ; return ( JCMethodInvocation ) exec . expr ; }
|
Return the first call in a constructor definition .
|
1,019 |
public static boolean isDiamond ( JCTree tree ) { switch ( tree . getTag ( ) ) { case TYPEAPPLY : return ( ( JCTypeApply ) tree ) . getTypeArguments ( ) . isEmpty ( ) ; case NEWCLASS : return isDiamond ( ( ( JCNewClass ) tree ) . clazz ) ; case ANNOTATED_TYPE : return isDiamond ( ( ( JCAnnotatedType ) tree ) . underlyingType ) ; default : return false ; } }
|
Return true if a tree represents a diamond new expr .
|
1,020 |
public static boolean isAnonymousDiamond ( JCTree tree ) { switch ( tree . getTag ( ) ) { case NEWCLASS : { JCNewClass nc = ( JCNewClass ) tree ; return nc . def != null && isDiamond ( nc . clazz ) ; } case ANNOTATED_TYPE : return isAnonymousDiamond ( ( ( JCAnnotatedType ) tree ) . underlyingType ) ; default : return false ; } }
|
Return true if the given tree represents a type elided anonymous class instance creation .
|
1,021 |
public static void setPolyKind ( JCTree tree , PolyKind pkind ) { switch ( tree . getTag ( ) ) { case APPLY : ( ( JCMethodInvocation ) tree ) . polyKind = pkind ; break ; case NEWCLASS : ( ( JCNewClass ) tree ) . polyKind = pkind ; break ; case REFERENCE : ( ( JCMemberReference ) tree ) . refPolyKind = pkind ; break ; default : throw new AssertionError ( "Unexpected tree: " + tree ) ; } }
|
set polyKind on given tree
|
1,022 |
public static void setVarargsElement ( JCTree tree , Type varargsElement ) { switch ( tree . getTag ( ) ) { case APPLY : ( ( JCMethodInvocation ) tree ) . varargsElement = varargsElement ; break ; case NEWCLASS : ( ( JCNewClass ) tree ) . varargsElement = varargsElement ; break ; case REFERENCE : ( ( JCMemberReference ) tree ) . varargsElement = varargsElement ; break ; default : throw new AssertionError ( "Unexpected tree: " + tree ) ; } }
|
set varargsElement on given tree
|
1,023 |
public static boolean isExpressionStatement ( JCExpression tree ) { switch ( tree . getTag ( ) ) { case PREINC : case PREDEC : case POSTINC : case POSTDEC : case ASSIGN : case BITOR_ASG : case BITXOR_ASG : case BITAND_ASG : case SL_ASG : case SR_ASG : case USR_ASG : case PLUS_ASG : case MINUS_ASG : case MUL_ASG : case DIV_ASG : case MOD_ASG : case APPLY : case NEWCLASS : case ERRONEOUS : return true ; default : return false ; } }
|
Return true if the tree corresponds to an expression statement
|
1,024 |
public static boolean isStatement ( JCTree tree ) { return ( tree instanceof JCStatement ) && ! tree . hasTag ( CLASSDEF ) && ! tree . hasTag ( Tag . BLOCK ) && ! tree . hasTag ( METHODDEF ) ; }
|
Return true if the tree corresponds to a statement
|
1,025 |
public static boolean isStaticSelector ( JCTree base , Names names ) { if ( base == null ) return false ; switch ( base . getTag ( ) ) { case IDENT : JCIdent id = ( JCIdent ) base ; return id . name != names . _this && id . name != names . _super && isStaticSym ( base ) ; case SELECT : return isStaticSym ( base ) && isStaticSelector ( ( ( JCFieldAccess ) base ) . selected , names ) ; case TYPEAPPLY : case TYPEARRAY : return true ; case ANNOTATED_TYPE : return isStaticSelector ( ( ( JCAnnotatedType ) base ) . underlyingType , names ) ; default : return false ; } }
|
Return true if the AST corresponds to a static select of the kind A . B
|
1,026 |
public static boolean isNull ( JCTree tree ) { if ( ! tree . hasTag ( LITERAL ) ) return false ; JCLiteral lit = ( JCLiteral ) tree ; return ( lit . typetag == BOT ) ; }
|
Return true if a tree represents the null literal .
|
1,027 |
public static boolean isInAnnotation ( Env < ? > env , JCTree tree ) { TreePath tp = TreePath . getPath ( env . toplevel , tree ) ; if ( tp != null ) { for ( Tree t : tp ) { if ( t . getKind ( ) == Tree . Kind . ANNOTATION ) return true ; } } return false ; }
|
Return true iff this tree is a child of some annotation .
|
1,028 |
public static int firstStatPos ( JCTree tree ) { if ( tree . hasTag ( BLOCK ) && ( ( JCBlock ) tree ) . stats . nonEmpty ( ) ) return ( ( JCBlock ) tree ) . stats . head . pos ; else return tree . pos ; }
|
The position of the first statement in a block or the position of the block itself if it is empty .
|
1,029 |
public static int endPos ( JCTree tree ) { if ( tree . hasTag ( BLOCK ) && ( ( JCBlock ) tree ) . endpos != Position . NOPOS ) return ( ( JCBlock ) tree ) . endpos ; else if ( tree . hasTag ( SYNCHRONIZED ) ) return endPos ( ( ( JCSynchronized ) tree ) . body ) ; else if ( tree . hasTag ( TRY ) ) { JCTry t = ( JCTry ) tree ; return endPos ( ( t . finalizer != null ) ? t . finalizer : ( t . catchers . nonEmpty ( ) ? t . catchers . last ( ) . body : t . body ) ) ; } else return tree . pos ; }
|
The end position of given tree if it is a block with defined endpos .
|
1,030 |
public static DiagnosticPosition diagEndPos ( final JCTree tree ) { final int endPos = TreeInfo . endPos ( tree ) ; return new DiagnosticPosition ( ) { public JCTree getTree ( ) { return tree ; } public int getStartPosition ( ) { return TreeInfo . getStartPos ( tree ) ; } public int getPreferredPosition ( ) { return endPos ; } public int getEndPosition ( EndPosTable endPosTable ) { return TreeInfo . getEndPos ( tree , endPosTable ) ; } } ; }
|
A DiagnosticPosition with the preferred position set to the end position of given tree if it is a block with defined endpos .
|
1,031 |
public static JCTree referencedStatement ( JCLabeledStatement tree ) { JCTree t = tree ; do t = ( ( JCLabeledStatement ) t ) . body ; while ( t . hasTag ( LABELLED ) ) ; switch ( t . getTag ( ) ) { case DOLOOP : case WHILELOOP : case FORLOOP : case FOREACHLOOP : case SWITCH : return t ; default : return tree ; } }
|
Return the statement referenced by a label . If the label refers to a loop or switch return that switch otherwise return the labelled statement itself
|
1,032 |
public static Name name ( JCTree tree ) { switch ( tree . getTag ( ) ) { case IDENT : return ( ( JCIdent ) tree ) . name ; case SELECT : return ( ( JCFieldAccess ) tree ) . name ; case TYPEAPPLY : return name ( ( ( JCTypeApply ) tree ) . clazz ) ; default : return null ; } }
|
If this tree is an identifier or a field or a parameterized type return its name otherwise return null .
|
1,033 |
public static Name fullName ( JCTree tree ) { tree = skipParens ( tree ) ; switch ( tree . getTag ( ) ) { case IDENT : return ( ( JCIdent ) tree ) . name ; case SELECT : Name sname = fullName ( ( ( JCFieldAccess ) tree ) . selected ) ; return sname == null ? null : sname . append ( '.' , name ( tree ) ) ; default : return null ; } }
|
If this tree is a qualified identifier its return fully qualified name otherwise return null .
|
1,034 |
public static Symbol symbol ( JCTree tree ) { tree = skipParens ( tree ) ; switch ( tree . getTag ( ) ) { case IDENT : return ( ( JCIdent ) tree ) . sym ; case SELECT : return ( ( JCFieldAccess ) tree ) . sym ; case TYPEAPPLY : return symbol ( ( ( JCTypeApply ) tree ) . clazz ) ; case ANNOTATED_TYPE : return symbol ( ( ( JCAnnotatedType ) tree ) . underlyingType ) ; case REFERENCE : return ( ( JCMemberReference ) tree ) . sym ; default : return null ; } }
|
If this tree is an identifier or a field return its symbol otherwise return null .
|
1,035 |
public static boolean nonstaticSelect ( JCTree tree ) { tree = skipParens ( tree ) ; if ( ! tree . hasTag ( SELECT ) ) return false ; JCFieldAccess s = ( JCFieldAccess ) tree ; Symbol e = symbol ( s . selected ) ; return e == null || ( e . kind != PCK && e . kind != TYP ) ; }
|
Return true if this is a nonstatic selection .
|
1,036 |
public static void setSymbol ( JCTree tree , Symbol sym ) { tree = skipParens ( tree ) ; switch ( tree . getTag ( ) ) { case IDENT : ( ( JCIdent ) tree ) . sym = sym ; break ; case SELECT : ( ( JCFieldAccess ) tree ) . sym = sym ; break ; default : } }
|
If this tree is an identifier or a field set its symbol otherwise skip .
|
1,037 |
public static long flags ( JCTree tree ) { switch ( tree . getTag ( ) ) { case VARDEF : return ( ( JCVariableDecl ) tree ) . mods . flags ; case METHODDEF : return ( ( JCMethodDecl ) tree ) . mods . flags ; case CLASSDEF : return ( ( JCClassDecl ) tree ) . mods . flags ; case BLOCK : return ( ( JCBlock ) tree ) . flags ; default : return 0 ; } }
|
If this tree is a declaration or a block return its flags field otherwise return 0 .
|
1,038 |
public static int opPrec ( JCTree . Tag op ) { switch ( op ) { case POS : case NEG : case NOT : case COMPL : case PREINC : case PREDEC : return prefixPrec ; case POSTINC : case POSTDEC : case NULLCHK : return postfixPrec ; case ASSIGN : return assignPrec ; case BITOR_ASG : case BITXOR_ASG : case BITAND_ASG : case SL_ASG : case SR_ASG : case USR_ASG : case PLUS_ASG : case MINUS_ASG : case MUL_ASG : case DIV_ASG : case MOD_ASG : return assignopPrec ; case OR : return orPrec ; case AND : return andPrec ; case EQ : case NE : return eqPrec ; case LT : case GT : case LE : case GE : return ordPrec ; case BITOR : return bitorPrec ; case BITXOR : return bitxorPrec ; case BITAND : return bitandPrec ; case SL : case SR : case USR : return shiftPrec ; case PLUS : case MINUS : return addPrec ; case MUL : case DIV : case MOD : return mulPrec ; case TYPETEST : return ordPrec ; default : throw new AssertionError ( ) ; } }
|
Map operators to their precedence levels .
|
1,039 |
public static JCExpression typeIn ( JCExpression tree ) { switch ( tree . getTag ( ) ) { case ANNOTATED_TYPE : return ( ( JCAnnotatedType ) tree ) . underlyingType ; case IDENT : case TYPEIDENT : case SELECT : case TYPEARRAY : case WILDCARD : case TYPEPARAMETER : case TYPEAPPLY : case ERRONEOUS : return tree ; default : throw new AssertionError ( "Unexpected type tree: " + tree ) ; } }
|
Returns the underlying type of the tree if it is an annotated type or the tree itself otherwise .
|
1,040 |
private String [ ] tokenize ( String s , char separator , int maxTokens ) { List < String > tokens = new ArrayList < > ( ) ; StringBuilder token = new StringBuilder ( ) ; boolean prevIsEscapeChar = false ; for ( int i = 0 ; i < s . length ( ) ; i += Character . charCount ( i ) ) { int currentChar = s . codePointAt ( i ) ; if ( prevIsEscapeChar ) { token . appendCodePoint ( currentChar ) ; prevIsEscapeChar = false ; } else if ( currentChar == separator && tokens . size ( ) < maxTokens - 1 ) { tokens . add ( token . toString ( ) ) ; token = new StringBuilder ( ) ; } else if ( currentChar == '\\' ) { prevIsEscapeChar = true ; } else { token . appendCodePoint ( currentChar ) ; } } if ( token . length ( ) > 0 ) { tokens . add ( token . toString ( ) ) ; } return tokens . toArray ( new String [ ] { } ) ; }
|
Given a string return an array of tokens . The separator can be escaped with the \ character . The \ character may also be escaped by the \ character .
|
1,041 |
public static String addTrailingFileSep ( String path ) { String fs = System . getProperty ( "file.separator" ) ; String dblfs = fs + fs ; int indexDblfs ; while ( ( indexDblfs = path . indexOf ( dblfs , 1 ) ) >= 0 ) { path = path . substring ( 0 , indexDblfs ) + path . substring ( indexDblfs + fs . length ( ) ) ; } if ( ! path . endsWith ( fs ) ) path += fs ; return path ; }
|
Add a trailing file separator if not found . Remove superfluous file separators if any . Preserve the front double file separator for UNC paths .
|
1,042 |
private boolean checkOutputFileEncoding ( String docencoding , DocErrorReporter reporter ) { OutputStream ost = new ByteArrayOutputStream ( ) ; OutputStreamWriter osw = null ; try { osw = new OutputStreamWriter ( ost , docencoding ) ; } catch ( UnsupportedEncodingException exc ) { reporter . printError ( getText ( "doclet.Encoding_not_supported" , docencoding ) ) ; return false ; } finally { try { if ( osw != null ) { osw . close ( ) ; } } catch ( IOException exc ) { } } return true ; }
|
Check the validity of the given Source or Output File encoding on this platform .
|
1,043 |
public boolean shouldExcludeQualifier ( String qualifier ) { if ( excludedQualifiers . contains ( "all" ) || excludedQualifiers . contains ( qualifier ) || excludedQualifiers . contains ( qualifier + ".*" ) ) { return true ; } else { int index = - 1 ; while ( ( index = qualifier . indexOf ( "." , index + 1 ) ) != - 1 ) { if ( excludedQualifiers . contains ( qualifier . substring ( 0 , index + 1 ) + "*" ) ) { return true ; } } return false ; } }
|
Return true if the given qualifier should be excluded and false otherwise .
|
1,044 |
public boolean isGeneratedDoc ( ClassDoc cd ) { if ( ! nodeprecated ) { return true ; } return ! ( utils . isDeprecated ( cd ) || utils . isDeprecated ( cd . containingPackage ( ) ) ) ; }
|
Return true if the ClassDoc element is getting documented depending upon - nodeprecated option and the deprecation information . Return true if - nodeprecated is not used . Return false if - nodeprecated is used and if either ClassDoc element is deprecated or the containing package is deprecated .
|
1,045 |
public InputStream getBuilderXML ( ) throws IOException { return builderXMLPath == null ? Configuration . class . getResourceAsStream ( DEFAULT_BUILDER_XML ) : DocFile . createFileForInput ( this , builderXMLPath ) . openInputStream ( ) ; }
|
Return the input stream to the builder XML .
|
1,046 |
public static JavaCompiler instance ( Context context ) { JavaCompiler instance = context . get ( compilerKey ) ; if ( instance == null ) instance = new JavaCompiler ( context ) ; return instance ; }
|
Get the JavaCompiler instance for this context .
|
1,047 |
public CharSequence readSource ( JavaFileObject filename ) { try { inputFiles . add ( filename ) ; return filename . getCharContent ( false ) ; } catch ( IOException e ) { log . error ( "error.reading.file" , filename , JavacFileManager . getMessage ( e ) ) ; return null ; } }
|
Try to open input stream with given name . Report an error if this fails .
|
1,048 |
protected JCCompilationUnit parse ( JavaFileObject filename , CharSequence content ) { long msec = now ( ) ; JCCompilationUnit tree = make . TopLevel ( List . nil ( ) ) ; if ( content != null ) { if ( verbose ) { log . printVerbose ( "parsing.started" , filename ) ; } if ( ! taskListener . isEmpty ( ) ) { TaskEvent e = new TaskEvent ( TaskEvent . Kind . PARSE , filename ) ; taskListener . started ( e ) ; keepComments = true ; genEndPos = true ; } Parser parser = parserFactory . newParser ( content , keepComments ( ) , genEndPos , lineDebugInfo , filename . isNameCompatible ( "module-info" , Kind . SOURCE ) ) ; tree = parser . parseCompilationUnit ( ) ; if ( verbose ) { log . printVerbose ( "parsing.done" , Long . toString ( elapsed ( msec ) ) ) ; } } tree . sourcefile = filename ; if ( content != null && ! taskListener . isEmpty ( ) ) { TaskEvent e = new TaskEvent ( TaskEvent . Kind . PARSE , tree ) ; taskListener . finished ( e ) ; } return tree ; }
|
Parse contents of input stream .
|
1,049 |
JavaFileObject genCode ( Env < AttrContext > env , JCClassDecl cdef ) throws IOException { try { if ( gen . genClass ( env , cdef ) && ( errorCount ( ) == 0 ) ) return writer . writeClass ( cdef . sym ) ; } catch ( ClassWriter . PoolOverflow ex ) { log . error ( cdef . pos ( ) , "limit.pool" ) ; } catch ( ClassWriter . StringOverflow ex ) { log . error ( cdef . pos ( ) , "limit.string.overflow" , ex . value . substring ( 0 , 20 ) ) ; } catch ( CompletionFailure ex ) { chk . completionError ( cdef . pos ( ) , ex ) ; } return null ; }
|
Generate code and emit a class file for a given class
|
1,050 |
public void readSourceFile ( JCCompilationUnit tree , ClassSymbol c ) throws CompletionFailure { if ( completionFailureName == c . fullname ) { throw new CompletionFailure ( c , "user-selected completion failure by class name" ) ; } JavaFileObject filename = c . classfile ; JavaFileObject prev = log . useSource ( filename ) ; if ( tree == null ) { try { tree = parse ( filename , filename . getCharContent ( false ) ) ; } catch ( IOException e ) { log . error ( "error.reading.file" , filename , JavacFileManager . getMessage ( e ) ) ; tree = make . TopLevel ( List . < JCTree > nil ( ) ) ; } finally { log . useSource ( prev ) ; } } if ( ! taskListener . isEmpty ( ) ) { TaskEvent e = new TaskEvent ( TaskEvent . Kind . ENTER , tree ) ; taskListener . started ( e ) ; } if ( ! modules . enter ( List . of ( tree ) , c ) ) { throw new CompletionFailure ( c , diags . fragment ( "cant.resolve.modules" ) ) ; } enter . complete ( List . of ( tree ) , c ) ; if ( ! taskListener . isEmpty ( ) ) { TaskEvent e = new TaskEvent ( TaskEvent . Kind . ENTER , tree ) ; taskListener . finished ( e ) ; } if ( enter . getEnv ( c ) == null ) { boolean isPkgInfo = tree . sourcefile . isNameCompatible ( "package-info" , JavaFileObject . Kind . SOURCE ) ; boolean isModuleInfo = tree . sourcefile . isNameCompatible ( "module-info" , JavaFileObject . Kind . SOURCE ) ; if ( isModuleInfo ) { if ( enter . getEnv ( tree . modle ) == null ) { JCDiagnostic diag = diagFactory . fragment ( "file.does.not.contain.module" ) ; throw new ClassFinder . BadClassFile ( c , filename , diag , diagFactory ) ; } } else if ( isPkgInfo ) { if ( enter . getEnv ( tree . packge ) == null ) { JCDiagnostic diag = diagFactory . fragment ( "file.does.not.contain.package" , c . location ( ) ) ; throw new ClassFinder . BadClassFile ( c , filename , diag , diagFactory ) ; } } else { JCDiagnostic diag = diagFactory . fragment ( "file.doesnt.contain.class" , c . getQualifiedName ( ) ) ; throw new ClassFinder . BadClassFile ( c , filename , diag , diagFactory ) ; } } implicitSourceFilesRead = true ; }
|
Compile a ClassSymbol from source optionally using the given compilation unit as the source tree .
|
1,051 |
public List < JCCompilationUnit > parseFiles ( Iterable < JavaFileObject > fileObjects ) { if ( shouldStop ( CompileState . PARSE ) ) return List . nil ( ) ; ListBuffer < JCCompilationUnit > trees = new ListBuffer < > ( ) ; Set < JavaFileObject > filesSoFar = new HashSet < > ( ) ; for ( JavaFileObject fileObject : fileObjects ) { if ( ! filesSoFar . contains ( fileObject ) ) { filesSoFar . add ( fileObject ) ; trees . append ( parse ( fileObject ) ) ; } } return trees . toList ( ) ; }
|
Parses a list of files .
|
1,052 |
public void initProcessAnnotations ( Iterable < ? extends Processor > processors , Collection < ? extends JavaFileObject > initialFiles , Collection < String > initialClassNames ) { if ( options . isSet ( PROC , "none" ) ) { processAnnotations = false ; } else if ( procEnvImpl == null ) { procEnvImpl = JavacProcessingEnvironment . instance ( context ) ; procEnvImpl . setProcessors ( processors ) ; processAnnotations = procEnvImpl . atLeastOneProcessor ( ) ; if ( processAnnotations ) { options . put ( "parameters" , "parameters" ) ; reader . saveParameterNames = true ; keepComments = true ; genEndPos = true ; if ( ! taskListener . isEmpty ( ) ) taskListener . started ( new TaskEvent ( TaskEvent . Kind . ANNOTATION_PROCESSING ) ) ; deferredDiagnosticHandler = new Log . DeferredDiagnosticHandler ( log ) ; procEnvImpl . getFiler ( ) . setInitialState ( initialFiles , initialClassNames ) ; } else { procEnvImpl . close ( ) ; } } }
|
Check if we should process annotations . If so and if no scanner is yet registered then set up the DocCommentScanner to catch doc comments and set keepComments so the parser records them in the compilation unit .
|
1,053 |
public void processAnnotations ( List < JCCompilationUnit > roots , Collection < String > classnames ) { if ( shouldStop ( CompileState . PROCESS ) ) { if ( unrecoverableError ( ) ) { deferredDiagnosticHandler . reportDeferredDiagnostics ( ) ; log . popDiagnosticHandler ( deferredDiagnosticHandler ) ; return ; } } if ( ! processAnnotations ) { if ( options . isSet ( PROC , "only" ) ) { log . warning ( "proc.proc-only.requested.no.procs" ) ; todo . clear ( ) ; } if ( ! classnames . isEmpty ( ) ) { log . error ( "proc.no.explicit.annotation.processing.requested" , classnames ) ; } Assert . checkNull ( deferredDiagnosticHandler ) ; return ; } Assert . checkNonNull ( deferredDiagnosticHandler ) ; try { List < ClassSymbol > classSymbols = List . nil ( ) ; List < PackageSymbol > pckSymbols = List . nil ( ) ; if ( ! classnames . isEmpty ( ) ) { if ( ! explicitAnnotationProcessingRequested ( ) ) { log . error ( "proc.no.explicit.annotation.processing.requested" , classnames ) ; deferredDiagnosticHandler . reportDeferredDiagnostics ( ) ; log . popDiagnosticHandler ( deferredDiagnosticHandler ) ; return ; } else { boolean errors = false ; for ( String nameStr : classnames ) { Symbol sym = resolveBinaryNameOrIdent ( nameStr ) ; if ( sym == null || ( sym . kind == PCK && ! processPcks ) || sym . kind == ABSENT_TYP ) { if ( sym != silentFail ) log . error ( Errors . ProcCantFindClass ( nameStr ) ) ; errors = true ; continue ; } try { if ( sym . kind == PCK ) sym . complete ( ) ; if ( sym . exists ( ) ) { if ( sym . kind == PCK ) pckSymbols = pckSymbols . prepend ( ( PackageSymbol ) sym ) ; else classSymbols = classSymbols . prepend ( ( ClassSymbol ) sym ) ; continue ; } Assert . check ( sym . kind == PCK ) ; log . warning ( Warnings . ProcPackageDoesNotExist ( nameStr ) ) ; pckSymbols = pckSymbols . prepend ( ( PackageSymbol ) sym ) ; } catch ( CompletionFailure e ) { log . error ( Errors . ProcCantFindClass ( nameStr ) ) ; errors = true ; continue ; } } if ( errors ) { deferredDiagnosticHandler . reportDeferredDiagnostics ( ) ; log . popDiagnosticHandler ( deferredDiagnosticHandler ) ; return ; } } } try { annotationProcessingOccurred = procEnvImpl . doProcessing ( roots , classSymbols , pckSymbols , deferredDiagnosticHandler ) ; } finally { procEnvImpl . close ( ) ; } } catch ( CompletionFailure ex ) { log . error ( "cant.access" , ex . sym , ex . getDetailValue ( ) ) ; if ( deferredDiagnosticHandler != null ) { deferredDiagnosticHandler . reportDeferredDiagnostics ( ) ; log . popDiagnosticHandler ( deferredDiagnosticHandler ) ; } } }
|
or determined to be transient and therefore suppressed .
|
1,054 |
public Queue < Env < AttrContext > > attribute ( Queue < Env < AttrContext > > envs ) { ListBuffer < Env < AttrContext > > results = new ListBuffer < > ( ) ; while ( ! envs . isEmpty ( ) ) results . append ( attribute ( envs . remove ( ) ) ) ; return stopIfError ( CompileState . ATTR , results ) ; }
|
Attribute a list of parse trees such as found on the todo list . Note that attributing classes may cause additional files to be parsed and entered via the SourceCompleter . Attribution of the entries in the list does not stop if any errors occur .
|
1,055 |
public Env < AttrContext > attribute ( Env < AttrContext > env ) { if ( compileStates . isDone ( env , CompileState . ATTR ) ) return env ; if ( verboseCompilePolicy ) printNote ( "[attribute " + env . enclClass . sym + "]" ) ; if ( verbose ) log . printVerbose ( "checking.attribution" , env . enclClass . sym ) ; if ( ! taskListener . isEmpty ( ) ) { TaskEvent e = new TaskEvent ( TaskEvent . Kind . ANALYZE , env . toplevel , env . enclClass . sym ) ; taskListener . started ( e ) ; } JavaFileObject prev = log . useSource ( env . enclClass . sym . sourcefile != null ? env . enclClass . sym . sourcefile : env . toplevel . sourcefile ) ; try { attr . attrib ( env ) ; if ( errorCount ( ) > 0 && ! shouldStop ( CompileState . ATTR ) ) { attr . postAttr ( env . tree ) ; } compileStates . put ( env , CompileState . ATTR ) ; } finally { log . useSource ( prev ) ; } return env ; }
|
Attribute a parse tree .
|
1,056 |
public Queue < Env < AttrContext > > flow ( Queue < Env < AttrContext > > envs ) { ListBuffer < Env < AttrContext > > results = new ListBuffer < > ( ) ; for ( Env < AttrContext > env : envs ) { flow ( env , results ) ; } return stopIfError ( CompileState . FLOW , results ) ; }
|
Perform dataflow checks on attributed parse trees . These include checks for definite assignment and unreachable statements . If any errors occur an empty list will be returned .
|
1,057 |
public void generate ( Queue < Pair < Env < AttrContext > , JCClassDecl > > queue ) { generate ( queue , null ) ; }
|
Generates the source or class file for a list of classes . The decision to generate a source file or a class file is based upon the compiler s options . Generation stops if an error occurs while writing files .
|
1,058 |
public void printCount ( String kind , int count ) { if ( count != 0 ) { String key ; if ( count == 1 ) key = "count." + kind ; else key = "count." + kind + ".plural" ; log . printLines ( WriterKind . ERROR , key , String . valueOf ( count ) ) ; log . flush ( Log . WriterKind . ERROR ) ; } }
|
Print numbers of errors and warnings .
|
1,059 |
protected void buildModulePackagesIndexFile ( String title , boolean includeScript , ModuleElement mdle ) throws DocFileIOException { String windowOverview = configuration . getText ( title ) ; Content body = getBody ( includeScript , getWindowTitle ( windowOverview ) ) ; addNavigationBarHeader ( body ) ; addOverviewHeader ( body ) ; addModulePackagesIndex ( body , mdle ) ; addOverview ( body ) ; addNavigationBarFooter ( body ) ; printHtmlDocument ( configuration . metakeywords . getOverviewMetaKeywords ( title , configuration . doctitle ) , includeScript , body ) ; }
|
Generate and prints the contents in the module packages index file . Call appropriate methods from the sub - class in order to generate Frame or Non Frame format .
|
1,060 |
protected void addIndex ( Content body ) { addIndexContents ( configuration . modules , "doclet.Module_Summary" , configuration . getText ( "doclet.Member_Table_Summary" , configuration . getText ( "doclet.Module_Summary" ) , configuration . getText ( "doclet.modules" ) ) , body ) ; }
|
Adds the frame or non - frame module index to the documentation tree .
|
1,061 |
protected void addModulePackagesIndex ( Content body , ModuleElement mdle ) { addModulePackagesIndexContents ( "doclet.Module_Summary" , configuration . getText ( "doclet.Member_Table_Summary" , configuration . getText ( "doclet.Module_Summary" ) , configuration . getText ( "doclet.modules" ) ) , body , mdle ) ; }
|
Adds the frame or non - frame module packages index to the documentation tree .
|
1,062 |
protected void addIndexContents ( Collection < ModuleElement > modules , String text , String tableSummary , Content body ) { HtmlTree htmlTree = ( configuration . allowTag ( HtmlTag . NAV ) ) ? HtmlTree . NAV ( ) : new HtmlTree ( HtmlTag . DIV ) ; htmlTree . addStyle ( HtmlStyle . indexNav ) ; HtmlTree ul = new HtmlTree ( HtmlTag . UL ) ; addAllClassesLink ( ul ) ; addAllPackagesLink ( ul ) ; htmlTree . addContent ( ul ) ; body . addContent ( htmlTree ) ; addModulesList ( modules , text , tableSummary , body ) ; }
|
Adds module index contents . Call appropriate methods from the sub - classes . Adds it to the body HtmlTree
|
1,063 |
protected void addModulePackagesIndexContents ( String text , String tableSummary , Content body , ModuleElement mdle ) { HtmlTree htmlTree = ( configuration . allowTag ( HtmlTag . NAV ) ) ? HtmlTree . NAV ( ) : new HtmlTree ( HtmlTag . DIV ) ; htmlTree . addStyle ( HtmlStyle . indexNav ) ; HtmlTree ul = new HtmlTree ( HtmlTag . UL ) ; addAllClassesLink ( ul ) ; addAllPackagesLink ( ul ) ; addAllModulesLink ( ul ) ; htmlTree . addContent ( ul ) ; body . addContent ( htmlTree ) ; addModulePackagesList ( modules , text , tableSummary , body , mdle ) ; }
|
Adds module packages index contents . Call appropriate methods from the sub - classes . Adds it to the body HtmlTree
|
1,064 |
public String getEnclosingPackageName ( TypeElement te ) { PackageElement encl = configuration . utils . containingPackage ( te ) ; return ( encl . isUnnamed ( ) ) ? "" : ( encl . getQualifiedName ( ) + "." ) ; }
|
Get the enclosed name of the package
|
1,065 |
public static void generate ( ConfigurationImpl configuration ) throws DocFileIOException { DocPath filename = DocPaths . MODULE_OVERVIEW_FRAME ; ModuleIndexFrameWriter modulegen = new ModuleIndexFrameWriter ( configuration , filename ) ; modulegen . buildModuleIndexFile ( "doclet.Window_Overview" , false ) ; }
|
Generate the module index file named module - overview - frame . html .
|
1,066 |
protected Content getModuleLink ( ModuleElement mdle ) { Content moduleLinkContent ; Content mdlLabel = new StringContent ( mdle . getQualifiedName ( ) ) ; moduleLinkContent = getModuleFramesHyperLink ( mdle , mdlLabel , "packageListFrame" ) ; Content li = HtmlTree . LI ( moduleLinkContent ) ; return li ; }
|
Returns each module name as a separate link .
|
1,067 |
public SortedSet < Element > members ( VisibleMemberMap . Kind kind ) { TreeSet < Element > out = new TreeSet < > ( comparator ) ; out . addAll ( getVisibleMemberMap ( kind ) . getLeafMembers ( ) ) ; return out ; }
|
Returns a list of methods that will be documented for the given class . This information can be used for doclet specific documentation generation .
|
1,068 |
public Object constantValue ( ) { Object result = sym . getConstValue ( ) ; if ( result != null && sym . type . hasTag ( BOOLEAN ) ) result = Boolean . valueOf ( ( ( Integer ) result ) . intValue ( ) != 0 ) ; return result ; }
|
Get the value of a constant field .
|
1,069 |
static String constantValueExpression ( Object cb ) { if ( cb == null ) return null ; if ( cb instanceof Character ) return sourceForm ( ( ( Character ) cb ) . charValue ( ) ) ; if ( cb instanceof Byte ) return sourceForm ( ( ( Byte ) cb ) . byteValue ( ) ) ; if ( cb instanceof String ) return sourceForm ( ( String ) cb ) ; if ( cb instanceof Double ) return sourceForm ( ( ( Double ) cb ) . doubleValue ( ) , 'd' ) ; if ( cb instanceof Float ) return sourceForm ( ( ( Float ) cb ) . doubleValue ( ) , 'f' ) ; if ( cb instanceof Long ) return cb + "L" ; return cb . toString ( ) ; }
|
A static version of the above .
|
1,070 |
private static boolean parse ( Class < ? > service , URL u ) throws ServiceConfigurationError { InputStream in = null ; BufferedReader r = null ; try { in = u . openStream ( ) ; r = new BufferedReader ( new InputStreamReader ( in , "utf-8" ) ) ; int lc = 1 ; String ln ; while ( ( ln = r . readLine ( ) ) != null ) { int ci = ln . indexOf ( '#' ) ; if ( ci >= 0 ) ln = ln . substring ( 0 , ci ) ; ln = ln . trim ( ) ; int n = ln . length ( ) ; if ( n != 0 ) { if ( ( ln . indexOf ( ' ' ) >= 0 ) || ( ln . indexOf ( '\t' ) >= 0 ) ) fail ( service , u , lc , "Illegal configuration-file syntax" ) ; int cp = ln . codePointAt ( 0 ) ; if ( ! Character . isJavaIdentifierStart ( cp ) ) fail ( service , u , lc , "Illegal provider-class name: " + ln ) ; for ( int i = Character . charCount ( cp ) ; i < n ; i += Character . charCount ( cp ) ) { cp = ln . codePointAt ( i ) ; if ( ! Character . isJavaIdentifierPart ( cp ) && ( cp != '.' ) ) fail ( service , u , lc , "Illegal provider-class name: " + ln ) ; } return true ; } } } catch ( FileNotFoundException x ) { return false ; } catch ( IOException x ) { fail ( service , ": " + x ) ; } finally { try { if ( r != null ) r . close ( ) ; } catch ( IOException y ) { fail ( service , ": " + y ) ; } try { if ( in != null ) in . close ( ) ; } catch ( IOException y ) { fail ( service , ": " + y ) ; } } return false ; }
|
Parse the content of the given URL as a provider - configuration file .
|
1,071 |
public static boolean hasService ( Class < ? > service , URL [ ] urls ) throws ServiceConfigurationError { for ( URL url : urls ) { try { String fullName = prefix + service . getName ( ) ; URL u = new URL ( url , fullName ) ; boolean found = parse ( service , u ) ; if ( found ) return true ; } catch ( MalformedURLException e ) { } } return false ; }
|
Return true if a description for at least one service is found in the service configuration files in the given URLs .
|
1,072 |
public String formatDiagnostic ( JCDiagnostic d , Locale l ) { try { StringBuilder buf = new StringBuilder ( ) ; if ( d . getPosition ( ) != Position . NOPOS ) { buf . append ( formatSource ( d , false , null ) ) ; buf . append ( ':' ) ; buf . append ( formatPosition ( d , LINE , null ) ) ; buf . append ( ':' ) ; buf . append ( formatPosition ( d , COLUMN , null ) ) ; buf . append ( ':' ) ; } else if ( d . getSource ( ) != null && d . getSource ( ) . getKind ( ) == JavaFileObject . Kind . CLASS ) { buf . append ( formatSource ( d , false , null ) ) ; buf . append ( ":-:-:" ) ; } else buf . append ( '-' ) ; buf . append ( ' ' ) ; buf . append ( formatMessage ( d , null ) ) ; if ( displaySource ( d ) ) { buf . append ( "\n" ) ; buf . append ( formatSourceLine ( d , 0 ) ) ; } return buf . toString ( ) ; } catch ( Exception e ) { return null ; } }
|
provide common default formats
|
1,073 |
public static int zero ( int tc ) { switch ( tc ) { case INTcode : case BYTEcode : case SHORTcode : case CHARcode : return iconst_0 ; case LONGcode : return lconst_0 ; case FLOATcode : return fconst_0 ; case DOUBLEcode : return dconst_0 ; default : throw new AssertionError ( "zero" ) ; } }
|
The opcode that loads a zero constant of a given type code .
|
1,074 |
int makeRef ( DiagnosticPosition pos , Type type ) { checkDimension ( pos , type ) ; if ( type . isAnnotated ( ) ) { return pool . put ( ( Object ) type ) ; } else { return pool . put ( type . hasTag ( CLASS ) ? ( Object ) type . tsym : ( Object ) type ) ; } }
|
Insert a reference to given type in the constant pool checking for an array with too many dimensions ; return the reference s index .
|
1,075 |
private void checkDimension ( DiagnosticPosition pos , Type t ) { switch ( t . getTag ( ) ) { case METHOD : checkDimension ( pos , t . getReturnType ( ) ) ; for ( List < Type > args = t . getParameterTypes ( ) ; args . nonEmpty ( ) ; args = args . tail ) checkDimension ( pos , args . head ) ; break ; case ARRAY : if ( types . dimensions ( t ) > ClassFile . MAX_DIMENSIONS ) { log . error ( pos , "limit.dimensions" ) ; nerrs ++ ; } break ; default : break ; } }
|
Check if the given type is an array with too many dimensions .
|
1,076 |
LocalItem makeTemp ( Type type ) { VarSymbol v = new VarSymbol ( Flags . SYNTHETIC , names . empty , type , env . enclMethod . sym ) ; code . newLocal ( v ) ; return items . makeLocalItem ( v ) ; }
|
Create a tempory variable .
|
1,077 |
void callMethod ( DiagnosticPosition pos , Type site , Name name , List < Type > argtypes , boolean isStatic ) { Symbol msym = rs . resolveInternalMethod ( pos , attrEnv , site , name , argtypes , null ) ; if ( isStatic ) items . makeStaticItem ( msym ) . invoke ( ) ; else items . makeMemberItem ( msym , name == names . init ) . invoke ( ) ; }
|
Generate code to call a non - private method or constructor .
|
1,078 |
private boolean isAccessSuper ( JCMethodDecl enclMethod ) { return ( enclMethod . mods . flags & SYNTHETIC ) != 0 && isOddAccessName ( enclMethod . name ) ; }
|
Is the given method definition an access method resulting from a qualified super? This is signified by an odd access code .
|
1,079 |
void genFinalizer ( Env < GenContext > env ) { if ( code . isAlive ( ) && env . info . finalize != null ) env . info . finalize . gen ( ) ; }
|
Generate code to invoke the finalizer associated with given environment . Any calls to finalizers are appended to the environments cont chain . Mark beginning of gap in catch all range for finalizer .
|
1,080 |
Env < GenContext > unwind ( JCTree target , Env < GenContext > env ) { Env < GenContext > env1 = env ; while ( true ) { genFinalizer ( env1 ) ; if ( env1 . tree == target ) break ; env1 = env1 . next ; } return env1 ; }
|
Generate code to call all finalizers of structures aborted by a non - local exit . Return target environment of the non - local exit .
|
1,081 |
void endFinalizerGap ( Env < GenContext > env ) { if ( env . info . gaps != null && env . info . gaps . length ( ) % 2 == 1 ) env . info . gaps . append ( code . curCP ( ) ) ; }
|
Mark end of gap in catch - all range for finalizer .
|
1,082 |
void endFinalizerGaps ( Env < GenContext > from , Env < GenContext > to ) { Env < GenContext > last = null ; while ( last != to ) { endFinalizerGap ( from ) ; last = from ; from = from . next ; } }
|
Mark end of all gaps in catch - all ranges for finalizers of environments lying between and including to two environments .
|
1,083 |
boolean hasFinally ( JCTree target , Env < GenContext > env ) { while ( env . tree != target ) { if ( env . tree . hasTag ( TRY ) && env . info . finalize . hasFinalizer ( ) ) return true ; env = env . next ; } return false ; }
|
Do any of the structures aborted by a non - local exit have finalizers that require an empty stack?
|
1,084 |
private void checkStringConstant ( DiagnosticPosition pos , Object constValue ) { if ( nerrs != 0 || constValue == null || ! ( constValue instanceof String ) || ( ( String ) constValue ) . length ( ) < Pool . MAX_STRING_LENGTH ) return ; log . error ( pos , "limit.string" ) ; nerrs ++ ; }
|
Check a constant value and report if it is a string that is too large .
|
1,085 |
void genMethod ( JCMethodDecl tree , Env < GenContext > env , boolean fatcode ) { MethodSymbol meth = tree . sym ; int extras = 0 ; if ( meth . isConstructor ( ) ) { extras ++ ; if ( meth . enclClass ( ) . isInner ( ) && ! meth . enclClass ( ) . isStatic ( ) ) { extras ++ ; } } else if ( ( tree . mods . flags & STATIC ) == 0 ) { extras ++ ; } if ( Code . width ( types . erasure ( env . enclMethod . sym . type ) . getParameterTypes ( ) ) + extras > ClassFile . MAX_PARAMETERS ) { log . error ( tree . pos ( ) , "limit.parameters" ) ; nerrs ++ ; } else if ( tree . body != null ) { int startpcCrt = initCode ( tree , env , fatcode ) ; try { genStat ( tree . body , env ) ; } catch ( CodeSizeOverflow e ) { startpcCrt = initCode ( tree , env , fatcode ) ; genStat ( tree . body , env ) ; } if ( code . state . stacksize != 0 ) { log . error ( tree . body . pos ( ) , "stack.sim.error" , tree ) ; throw new AssertionError ( ) ; } if ( code . isAlive ( ) ) { code . statBegin ( TreeInfo . endPos ( tree . body ) ) ; if ( env . enclMethod == null || env . enclMethod . sym . type . getReturnType ( ) . hasTag ( VOID ) ) { code . emitop0 ( return_ ) ; } else { int startpc = code . entryPoint ( ) ; CondItem c = items . makeCondItem ( goto_ ) ; code . resolve ( c . jumpTrue ( ) , startpc ) ; } } if ( genCrt ) code . crt . put ( tree . body , CRT_BLOCK , startpcCrt , code . curCP ( ) ) ; code . endScopes ( 0 ) ; if ( code . checkLimits ( tree . pos ( ) , log ) ) { nerrs ++ ; return ; } if ( ! fatcode && code . fatcode ) genMethod ( tree , env , true ) ; if ( stackMap == StackMapFormat . JSR202 ) { code . lastFrame = null ; code . frameBeforeLast = null ; } code . compressCatchTable ( ) ; code . fillExceptionParameterPositions ( ) ; } }
|
Generate code for a method .
|
1,086 |
private void genLoop ( JCStatement loop , JCStatement body , JCExpression cond , List < JCExpressionStatement > step , boolean testFirst ) { Env < GenContext > loopEnv = env . dup ( loop , new GenContext ( ) ) ; int startpc = code . entryPoint ( ) ; if ( testFirst ) { CondItem c ; if ( cond != null ) { code . statBegin ( cond . pos ) ; Assert . check ( code . state . stacksize == 0 ) ; c = genCond ( TreeInfo . skipParens ( cond ) , CRT_FLOW_CONTROLLER ) ; } else { c = items . makeCondItem ( goto_ ) ; } Chain loopDone = c . jumpFalse ( ) ; code . resolve ( c . trueJumps ) ; Assert . check ( code . state . stacksize == 0 ) ; genStat ( body , loopEnv , CRT_STATEMENT | CRT_FLOW_TARGET ) ; code . resolve ( loopEnv . info . cont ) ; genStats ( step , loopEnv ) ; code . resolve ( code . branch ( goto_ ) , startpc ) ; code . resolve ( loopDone ) ; } else { genStat ( body , loopEnv , CRT_STATEMENT | CRT_FLOW_TARGET ) ; code . resolve ( loopEnv . info . cont ) ; genStats ( step , loopEnv ) ; if ( code . isAlive ( ) ) { CondItem c ; if ( cond != null ) { code . statBegin ( cond . pos ) ; Assert . check ( code . state . stacksize == 0 ) ; c = genCond ( TreeInfo . skipParens ( cond ) , CRT_FLOW_CONTROLLER ) ; } else { c = items . makeCondItem ( goto_ ) ; } code . resolve ( c . jumpTrue ( ) , startpc ) ; Assert . check ( code . state . stacksize == 0 ) ; code . resolve ( c . falseJumps ) ; } } Chain exit = loopEnv . info . exit ; if ( exit != null ) { code . resolve ( exit ) ; exit . state . defined . excludeFrom ( code . nextreg ) ; } }
|
Generate code for a loop .
|
1,087 |
Item makeNewArray ( DiagnosticPosition pos , Type type , int ndims ) { Type elemtype = types . elemtype ( type ) ; if ( types . dimensions ( type ) > ClassFile . MAX_DIMENSIONS ) { log . error ( pos , "limit.dimensions" ) ; nerrs ++ ; } int elemcode = Code . arraycode ( elemtype ) ; if ( elemcode == 0 || ( elemcode == 1 && ndims == 1 ) ) { code . emitAnewarray ( makeRef ( pos , elemtype ) , type ) ; } else if ( elemcode == 1 ) { code . emitMultianewarray ( ndims , makeRef ( pos , type ) , type ) ; } else { code . emitNewarray ( elemcode , type ) ; } return items . makeStackItem ( type ) ; }
|
Generate code to create an array with given element type and number of dimensions .
|
1,088 |
Item completeBinop ( JCTree lhs , JCTree rhs , OperatorSymbol operator ) { MethodType optype = ( MethodType ) operator . type ; int opcode = operator . opcode ; if ( opcode >= if_icmpeq && opcode <= if_icmple && rhs . type . constValue ( ) instanceof Number && ( ( Number ) rhs . type . constValue ( ) ) . intValue ( ) == 0 ) { opcode = opcode + ( ifeq - if_icmpeq ) ; } else if ( opcode >= if_acmpeq && opcode <= if_acmpne && TreeInfo . isNull ( rhs ) ) { opcode = opcode + ( if_acmp_null - if_acmpeq ) ; } else { Type rtype = operator . erasure ( types ) . getParameterTypes ( ) . tail . head ; if ( opcode >= ishll && opcode <= lushrl ) { opcode = opcode + ( ishl - ishll ) ; rtype = syms . intType ; } genExpr ( rhs , rtype ) . load ( ) ; if ( opcode >= ( 1 << preShift ) ) { code . emitop0 ( opcode >> preShift ) ; opcode = opcode & 0xFF ; } } if ( opcode >= ifeq && opcode <= if_acmpne || opcode == if_acmp_null || opcode == if_acmp_nonnull ) { return items . makeCondItem ( opcode ) ; } else { code . emitop0 ( opcode ) ; return items . makeStackItem ( optype . restype ) ; } }
|
Complete generating code for operation with left operand already on stack .
|
1,089 |
public boolean genClass ( Env < AttrContext > env , JCClassDecl cdef ) { try { attrEnv = env ; ClassSymbol c = cdef . sym ; this . toplevel = env . toplevel ; this . endPosTable = toplevel . endPositions ; c . pool = pool ; pool . reset ( ) ; cdef . defs = normalizeDefs ( cdef . defs , c ) ; generateReferencesToPrunedTree ( c , pool ) ; Env < GenContext > localEnv = new Env < > ( cdef , new GenContext ( ) ) ; localEnv . toplevel = env . toplevel ; localEnv . enclClass = cdef ; for ( List < JCTree > l = cdef . defs ; l . nonEmpty ( ) ; l = l . tail ) { genDef ( l . head , localEnv ) ; } if ( pool . numEntries ( ) > Pool . MAX_ENTRIES ) { log . error ( cdef . pos ( ) , "limit.pool" ) ; nerrs ++ ; } if ( nerrs != 0 ) { for ( List < JCTree > l = cdef . defs ; l . nonEmpty ( ) ; l = l . tail ) { if ( l . head . hasTag ( METHODDEF ) ) ( ( JCMethodDecl ) l . head ) . sym . code = null ; } } cdef . defs = List . nil ( ) ; return nerrs == 0 ; } finally { attrEnv = null ; this . env = null ; toplevel = null ; endPosTable = null ; nerrs = 0 ; } }
|
Generate code for a class definition .
|
1,090 |
public static Trees instance ( CompilationTask task ) { String taskClassName = task . getClass ( ) . getName ( ) ; if ( ! taskClassName . equals ( "com.sun.tools.javac.api.JavacTaskImpl" ) && ! taskClassName . equals ( "com.sun.tools.javac.api.BasicJavacTask" ) ) throw new IllegalArgumentException ( ) ; return getJavacTrees ( CompilationTask . class , task ) ; }
|
Returns a Trees object for a given CompilationTask .
|
1,091 |
private VirtualMachine listenTarget ( int port , List < String > remoteVMOptions ) { ListeningConnector listener = ( ListeningConnector ) connector ; File crashErrorFile = createTempFile ( "error" ) ; File crashOutputFile = createTempFile ( "output" ) ; try { String addr = listener . startListening ( connectorArgs ) ; debug ( "Listening at address: " + addr ) ; String javaHome = System . getProperty ( "java.home" ) ; List < String > args = new ArrayList < > ( ) ; args . add ( javaHome == null ? "java" : javaHome + File . separator + "bin" + File . separator + "java" ) ; args . add ( "-agentlib:jdwp=transport=" + connector . transport ( ) . name ( ) + ",address=" + addr ) ; args . addAll ( remoteVMOptions ) ; args . add ( remoteAgent ) ; args . add ( "" + port ) ; ProcessBuilder pb = new ProcessBuilder ( args ) ; pb . redirectError ( crashErrorFile ) ; pb . redirectOutput ( crashOutputFile ) ; process = pb . start ( ) ; vm = timedVirtualMachineCreation ( ( ) -> listener . accept ( connectorArgs ) , ( ) -> process . waitFor ( ) ) ; try { listener . stopListening ( connectorArgs ) ; } catch ( IOException | IllegalConnectorArgumentsException ex ) { } crashErrorFile . delete ( ) ; crashOutputFile . delete ( ) ; return vm ; } catch ( Throwable ex ) { if ( process != null ) { process . destroyForcibly ( ) ; } try { listener . stopListening ( connectorArgs ) ; } catch ( IOException | IllegalConnectorArgumentsException iex ) { } String text = readFile ( crashErrorFile ) + readFile ( crashOutputFile ) ; crashErrorFile . delete ( ) ; crashOutputFile . delete ( ) ; if ( text . isEmpty ( ) ) { throw reportLaunchFail ( ex , "listen" ) ; } else { throw new IllegalArgumentException ( text ) ; } } }
|
Directly launch the remote agent and connect JDI to it with a ListeningConnector .
|
1,092 |
private Map < String , String > launchArgs ( int port , String remoteVMOptions ) { Map < String , String > argumentName2Value = new HashMap < > ( ) ; argumentName2Value . put ( "main" , remoteAgent + " " + port ) ; argumentName2Value . put ( "options" , remoteVMOptions ) ; return argumentName2Value ; }
|
The JShell specific Connector args for the LaunchingConnector .
|
1,093 |
boolean doClassNames ( Collection < String > classNames ) throws IOException { if ( verbose ) { out . println ( "List of classes to process:" ) ; classNames . forEach ( out :: println ) ; out . println ( "End of class list." ) ; } if ( fm instanceof JavacFileManager ) { ( ( JavacFileManager ) fm ) . setSymbolFileEnabled ( false ) ; } fm . setLocation ( StandardLocation . CLASS_PATH , classPath ) ; if ( ! bootClassPath . isEmpty ( ) ) { fm . setLocation ( StandardLocation . PLATFORM_CLASS_PATH , bootClassPath ) ; } if ( ! systemModules . isEmpty ( ) ) { fm . setLocation ( StandardLocation . SYSTEM_MODULES , systemModules ) ; } LoadProc proc = new LoadProc ( ) ; JavaCompiler . CompilationTask task = compiler . getTask ( null , fm , this , options , classNames , null ) ; task . setProcessors ( List . of ( proc ) ) ; boolean r = task . call ( ) ; if ( r ) { if ( forRemoval ) { deprList = proc . getDeprecations ( ) . stream ( ) . filter ( DeprData :: isForRemoval ) . collect ( toList ( ) ) ; } else { deprList = proc . getDeprecations ( ) ; } } return r ; }
|
Processes a collection of class names . Names should fully qualified names in the form pkg . pkg . pkg . classname .
|
1,094 |
boolean processDirectory ( String dirname , Collection < String > classNames ) throws IOException { if ( ! Files . isDirectory ( Paths . get ( dirname ) ) ) { err . printf ( "%s: not a directory%n" , dirname ) ; return false ; } classPath . add ( 0 , new File ( dirname ) ) ; if ( classNames . isEmpty ( ) ) { Path base = Paths . get ( dirname ) ; int baseCount = base . getNameCount ( ) ; try ( Stream < Path > paths = Files . walk ( base ) ) { Stream < String > files = paths . filter ( p -> p . getNameCount ( ) > baseCount ) . map ( p -> p . subpath ( baseCount , p . getNameCount ( ) ) ) . map ( Path :: toString ) ; return doFileNames ( files ) ; } } else { return doClassNames ( classNames ) ; } }
|
Processes named class files in the given directory . The directory should be the root of a package hierarchy . If classNames is empty walks the directory hierarchy to find all classes .
|
1,095 |
boolean doJarFile ( String jarname ) throws IOException { try ( JarFile jf = new JarFile ( jarname ) ) { Stream < String > files = jf . stream ( ) . map ( JarEntry :: getName ) ; return doFileNames ( files ) ; } }
|
Processes all class files in the given jar file .
|
1,096 |
boolean processJarFile ( String jarname , Collection < String > classNames ) throws IOException { classPath . add ( 0 , new File ( jarname ) ) ; if ( classNames . isEmpty ( ) ) { return doJarFile ( jarname ) ; } else { return doClassNames ( classNames ) ; } }
|
Processes named class files from the given jar file or all classes if classNames is empty .
|
1,097 |
boolean processOldJdk ( String jdkHome , Collection < String > classNames ) throws IOException { String RTJAR = jdkHome + "/jre/lib/rt.jar" ; String CSJAR = jdkHome + "/jre/lib/charsets.jar" ; bootClassPath . add ( 0 , new File ( RTJAR ) ) ; bootClassPath . add ( 1 , new File ( CSJAR ) ) ; options . add ( "-source" ) ; options . add ( "8" ) ; if ( classNames . isEmpty ( ) ) { return doJarFile ( RTJAR ) ; } else { return doClassNames ( classNames ) ; } }
|
Processes named class files from rt . jar of a JDK version 7 or 8 . If classNames is empty processes all classes .
|
1,098 |
boolean processJdk9 ( String jdkHome , Collection < String > classes ) throws IOException { systemModules . add ( new File ( jdkHome ) ) ; return doClassNames ( classes ) ; }
|
Processes listed classes given a JDK 9 home .
|
1,099 |
boolean processRelease ( String release , Collection < String > classes ) throws IOException { options . addAll ( List . of ( "--release" , release ) ) ; if ( release . equals ( "9" ) ) { List < String > rootMods = List . of ( "java.se" , "java.se.ee" ) ; TraverseProc proc = new TraverseProc ( rootMods ) ; JavaCompiler . CompilationTask task = compiler . getTask ( null , fm , this , List . of ( "--add-modules" , String . join ( "," , rootMods ) ) , List . of ( "java.lang.Object" ) , null ) ; task . setProcessors ( List . of ( proc ) ) ; if ( ! task . call ( ) ) { return false ; } Map < PackageElement , List < TypeElement > > types = proc . getPublicTypes ( ) ; options . add ( "--add-modules" ) ; options . add ( String . join ( "," , rootMods ) ) ; return doClassNames ( types . values ( ) . stream ( ) . flatMap ( List :: stream ) . map ( TypeElement :: toString ) . collect ( toList ( ) ) ) ; } else { JavaCompiler compiler = ToolProvider . getSystemJavaCompiler ( ) ; StandardJavaFileManager fm = compiler . getStandardFileManager ( this , null , StandardCharsets . UTF_8 ) ; JavaCompiler . CompilationTask task = compiler . getTask ( null , fm , this , List . of ( "--release" , release ) , null , null ) ; List < Path > paths = new ArrayList < > ( ) ; for ( Path p : fm . getLocationAsPaths ( StandardLocation . PLATFORM_CLASS_PATH ) ) { try ( Stream < Path > str = Files . walk ( p ) ) { str . forEachOrdered ( paths :: add ) ; } } options . add ( "-Xlint:-options" ) ; return doClassNames ( paths . stream ( ) . filter ( path -> path . toString ( ) . endsWith ( ".sig" ) ) . map ( path -> path . subpath ( 1 , path . getNameCount ( ) ) ) . map ( Path :: toString ) . map ( s -> s . replaceAll ( "\\.sig$" , "" ) ) . map ( s -> s . replace ( '/' , '.' ) ) . collect ( toList ( ) ) ) ; } }
|
Process classes from a particular JDK release using only information in this JDK .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.