idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
500
public SortedSet < TypeElement > getVisibleClasses ( ) { SortedSet < TypeElement > vClasses = new TreeSet < > ( comparator ) ; vClasses . addAll ( visibleClasses ) ; return vClasses ; }
Return the list of visible classes in this map .
501
public List < Element > getLeafMembers ( ) { List < Element > result = new ArrayList < > ( ) ; result . addAll ( classMap . get ( typeElement ) . members ) ; result . addAll ( getInheritedPackagePrivateMethods ( ) ) ; return result ; }
Returns a list of visible enclosed members of the type being mapped . This list may also contain appended members inherited by inaccessible super types . These members are documented in the subtype when the super type is not documented .
502
public void resolve ( DatabindContext context , URIHandler handler ) { for ( ReferenceEntry entry : entries ( ) ) { entry . resolve ( context , handler ) ; } mapOfObjects . clear ( ) ; }
Resolves all reference entries that have been collected during deserialization .
503
private String englishLanguageFirstSentence ( String s ) { if ( s == null ) { return null ; } int len = s . length ( ) ; boolean period = false ; for ( int i = 0 ; i < len ; i ++ ) { switch ( s . charAt ( i ) ) { case '.' : period = true ; break ; case ' ' : case '\t' : case '\n' : case '\r' : case '\f' : if ( period ) { return s . substring ( 0 , i ) ; } break ; case '<' : if ( i > 0 ) { if ( htmlSentenceTerminatorFound ( s , i ) ) { return s . substring ( 0 , i ) ; } } break ; default : period = false ; } } return s ; }
Return the first sentence of a string where a sentence ends with a period followed be white space .
504
public boolean begin ( Class < ? > docletClass , Iterable < String > options , Iterable < ? extends JavaFileObject > fileObjects ) { this . docletClass = docletClass ; List < String > opts = new ArrayList < > ( ) ; for ( String opt : options ) opts . add ( opt ) ; return begin ( opts , fileObjects ) . isOK ( ) ; }
Called by 199 API .
505
private void checkOneArg ( List < String > args , int index ) throws OptionException { if ( ( index + 1 ) >= args . size ( ) || args . get ( index + 1 ) . startsWith ( "-d" ) ) { String text = messager . getText ( "main.requires_argument" , args . get ( index ) ) ; throw new OptionException ( CMDERR , this :: usage , text ) ; } }
Check the one arg option . Error and exit if one argument is not provided .
506
public ClassDoc exception ( ) { ClassDocImpl exceptionClass ; if ( ! ( holder instanceof ExecutableMemberDoc ) ) { exceptionClass = null ; } else { ExecutableMemberDocImpl emd = ( ExecutableMemberDocImpl ) holder ; ClassDocImpl con = ( ClassDocImpl ) emd . containingClass ( ) ; exceptionClass = ( ClassDocImpl ) con . findClass ( exceptionName ) ; } return exceptionClass ; }
Return the exception as a ClassDocImpl .
507
public String varValue ( VarSnippet snippet ) throws IllegalStateException { checkIfAlive ( ) ; checkValidSnippet ( snippet ) ; if ( snippet . status ( ) != Status . VALID ) { throw new IllegalArgumentException ( messageFormat ( "jshell.exc.var.not.valid" , snippet , snippet . status ( ) ) ) ; } String value ; try { value = executionControl ( ) . varValue ( snippet . classFullName ( ) , snippet . name ( ) ) ; } catch ( EngineTerminationException ex ) { throw new IllegalStateException ( ex . getMessage ( ) ) ; } catch ( ExecutionControlException ex ) { debug ( ex , "In varValue()" ) ; return "[" + ex . getMessage ( ) + "]" ; } return expunge ( value ) ; }
Get the current value of a variable .
508
private Snippet checkValidSnippet ( Snippet sn ) { if ( sn == null ) { throw new NullPointerException ( messageFormat ( "jshell.exc.null" ) ) ; } else { if ( sn . key ( ) . state ( ) != this ) { throw new IllegalArgumentException ( messageFormat ( "jshell.exc.alien" ) ) ; } return sn ; } }
Check a Snippet parameter coming from the API user
509
public Graph < Module > reduced ( ) { Graph < Module > graph = build ( ) ; Graph < Module > newGraph = buildGraph ( graph . edges ( ) ) . reduce ( ) ; if ( DEBUG ) { PrintWriter log = new PrintWriter ( System . err ) ; System . err . println ( "before transitive reduction: " ) ; graph . printGraph ( log ) ; System . err . println ( "after transitive reduction: " ) ; newGraph . printGraph ( log ) ; } return newGraph ; }
Apply transitive reduction on the resulting graph
510
private Graph < Module > buildGraph ( Map < Module , Set < Module > > edges ) { Graph . Builder < Module > builder = new Graph . Builder < > ( ) ; Set < Module > visited = new HashSet < > ( ) ; Deque < Module > deque = new LinkedList < > ( ) ; edges . entrySet ( ) . stream ( ) . forEach ( e -> { Module m = e . getKey ( ) ; deque . add ( m ) ; e . getValue ( ) . stream ( ) . forEach ( v -> { deque . add ( v ) ; builder . addEdge ( m , v ) ; } ) ; } ) ; Module source ; while ( ( source = deque . poll ( ) ) != null ) { if ( visited . contains ( source ) ) continue ; visited . add ( source ) ; builder . addNode ( source ) ; Module from = source ; requiresTransitive ( from ) . forEach ( m -> { deque . add ( m ) ; builder . addEdge ( from , m ) ; } ) ; } return builder . build ( ) ; }
Build a graph of module from the given dependences .
511
public int lookup ( Object key , int hash ) { Object node ; int hash1 = hash ^ ( hash >>> 15 ) ; int hash2 = ( hash ^ ( hash << 6 ) ) | 1 ; int deleted = - 1 ; for ( int i = hash1 & mask ; ; i = ( i + hash2 ) & mask ) { node = objs [ i ] ; if ( node == key ) return i ; if ( node == null ) return deleted >= 0 ? deleted : i ; if ( node == DELETED && deleted < 0 ) deleted = i ; } }
Find either the index of a key s value or the index of an available space .
512
public int getFromIndex ( int index ) { Object node = objs [ index ] ; return node == null || node == DELETED ? - 1 : ints [ index ] ; }
Return the value stored at the specified index in the table .
513
public int putAtIndex ( Object key , int value , int index ) { Object old = objs [ index ] ; if ( old == null || old == DELETED ) { objs [ index ] = key ; ints [ index ] = value ; if ( old != DELETED ) num_bindings ++ ; if ( 3 * num_bindings >= 2 * objs . length ) rehash ( ) ; return - 1 ; } else { int oldValue = ints [ index ] ; ints [ index ] = value ; return oldValue ; } }
Associates the specified key with the specified value in this map .
514
protected void rehash ( ) { Object [ ] oldObjsTable = objs ; int [ ] oldIntsTable = ints ; int oldCapacity = oldObjsTable . length ; int newCapacity = oldCapacity << 1 ; Object [ ] newObjTable = new Object [ newCapacity ] ; int [ ] newIntTable = new int [ newCapacity ] ; int newMask = newCapacity - 1 ; objs = newObjTable ; ints = newIntTable ; mask = newMask ; num_bindings = 0 ; Object key ; for ( int i = oldIntsTable . length ; -- i >= 0 ; ) { key = oldObjsTable [ i ] ; if ( key != null && key != DELETED ) putAtIndex ( key , oldIntsTable [ i ] , lookup ( key , hash ( key ) ) ) ; } }
Expand the hash table when it exceeds the load factor .
515
public static Todo instance ( Context context ) { Todo instance = context . get ( todoKey ) ; if ( instance == null ) instance = new Todo ( context ) ; return instance ; }
Get the Todo instance for this context .
516
public void retainFiles ( Collection < ? extends JavaFileObject > sourceFiles ) { for ( Iterator < Env < AttrContext > > it = contents . iterator ( ) ; it . hasNext ( ) ; ) { Env < AttrContext > env = it . next ( ) ; if ( ! sourceFiles . contains ( env . toplevel . sourcefile ) ) { if ( contentsByFile != null ) removeByFile ( env ) ; it . remove ( ) ; } } }
Removes all unattributed classes except those belonging to the given collection of files .
517
protected void putChar ( char ch , boolean scan ) { sbuf = ArrayUtils . ensureCapacity ( sbuf , sp ) ; sbuf [ sp ++ ] = ch ; if ( scan ) scanChar ( ) ; }
Append a character to sbuf .
518
protected int peekSurrogates ( ) { if ( surrogatesSupported && Character . isHighSurrogate ( ch ) ) { char high = ch ; int prevBP = bp ; scanChar ( ) ; char low = ch ; ch = high ; bp = prevBP ; if ( Character . isLowSurrogate ( low ) ) { return Character . toCodePoint ( high , low ) ; } } return - 1 ; }
Scan surrogate pairs . If ch is a high surrogate and the next character is a low surrogate returns the code point constructed from these surrogates . Otherwise returns - 1 . This method will not consume any of the characters .
519
protected Content getHead ( Element member ) { Content memberContent = new StringContent ( name ( member ) ) ; Content heading = HtmlTree . HEADING ( HtmlConstants . MEMBER_HEADING , memberContent ) ; return heading ; }
Get the header for the section .
520
public boolean showTabs ( ) { int value ; for ( MethodTypes type : EnumSet . allOf ( MethodTypes . class ) ) { value = type . tableTabs ( ) . value ( ) ; if ( ( value & methodTypesOr ) == value ) { methodTypes . add ( type ) ; } } boolean showTabs = methodTypes . size ( ) > 1 ; if ( showTabs ) { methodTypes . add ( MethodTypes . ALL ) ; } return showTabs ; }
Generate the method types set and return true if the method summary table needs to show tabs .
521
public void setSummaryColumnStyleAndScope ( HtmlTree thTree ) { thTree . addStyle ( HtmlStyle . colSecond ) ; thTree . addAttr ( HtmlAttr . SCOPE , "row" ) ; }
Set the style and scope attribute for the summary column .
522
static String [ ] removeArgsNotAffectingState ( String [ ] args ) { String [ ] out = new String [ args . length ] ; int j = 0 ; for ( int i = 0 ; i < args . length ; ++ i ) { if ( args [ i ] . equals ( "-j" ) ) { i ++ ; } else if ( args [ i ] . startsWith ( "--server:" ) ) { } else if ( args [ i ] . startsWith ( "--log=" ) ) { } else if ( args [ i ] . equals ( "--compare-found-sources" ) ) { i ++ ; } else { out [ j ] = args [ i ] ; j ++ ; } } String [ ] ret = new String [ j ] ; System . arraycopy ( out , 0 , ret , 0 , j ) ; return ret ; }
Remove args not affecting the state .
523
public void findAllArtifacts ( ) { binArtifacts = findAllFiles ( binDir ) ; gensrcArtifacts = findAllFiles ( gensrcDir ) ; headerArtifacts = findAllFiles ( headerDir ) ; }
Find all artifacts that exists on disk .
524
private Map < String , File > fetchPrevArtifacts ( String pkg ) { Package p = prev . packages ( ) . get ( pkg ) ; if ( p != null ) { return p . artifacts ( ) ; } return new HashMap < > ( ) ; }
Lookup the artifacts generated for this package in the previous build .
525
public void deleteClassArtifactsInTaintedPackages ( ) { for ( String pkg : taintedPackages ) { Map < String , File > arts = fetchPrevArtifacts ( pkg ) ; for ( File f : arts . values ( ) ) { if ( f . exists ( ) && f . getName ( ) . endsWith ( ".class" ) ) { f . delete ( ) ; } } } }
Delete all prev artifacts in the currently tainted packages .
526
public void taintPackage ( String name , String because ) { if ( ! taintedPackages . contains ( name ) ) { if ( because != null ) Log . debug ( "Tainting " + Util . justPackageName ( name ) + " because " + because ) ; taintedPackages . add ( name ) ; needsSaving ( ) ; Package nowp = now . packages ( ) . get ( name ) ; if ( nowp != null ) { for ( String d : nowp . dependents ( ) ) { taintPackage ( d , because ) ; } } } }
Mark a java package as tainted ie it needs recompilation .
527
public void checkSourceStatus ( boolean check_gensrc ) { removedSources = calculateRemovedSources ( ) ; for ( Source s : removedSources ) { if ( ! s . isGenerated ( ) || check_gensrc ) { taintPackage ( s . pkg ( ) . name ( ) , "source " + s . name ( ) + " was removed" ) ; } } addedSources = calculateAddedSources ( ) ; for ( Source s : addedSources ) { String msg = null ; if ( isIncremental ( ) ) { msg = "source " + s . name ( ) + " was added" ; } if ( ! s . isGenerated ( ) || check_gensrc ) { taintPackage ( s . pkg ( ) . name ( ) , msg ) ; } } modifiedSources = calculateModifiedSources ( ) ; for ( Source s : modifiedSources ) { if ( ! s . isGenerated ( ) || check_gensrc ) { taintPackage ( s . pkg ( ) . name ( ) , "source " + s . name ( ) + " was modified" ) ; } } }
Go through all sources and check which have been removed added or modified and taint the corresponding packages .
528
public Map < String , Transformer > getJavaSuffixRule ( ) { Map < String , Transformer > sr = new HashMap < > ( ) ; sr . put ( ".java" , compileJavaPackages ) ; return sr ; }
Acquire the compile_java_packages suffix rule for . java files .
529
public void taintPackagesThatMissArtifacts ( ) { for ( Package pkg : prev . packages ( ) . values ( ) ) { for ( File f : pkg . artifacts ( ) . values ( ) ) { if ( ! f . exists ( ) ) { taintPackage ( pkg . name ( ) , "" + f + " is missing." ) ; } } } }
If artifacts have gone missing force a recompile of the packages they belong to .
530
public void taintPackagesDependingOnChangedClasspathPackages ( ) throws IOException { Set < String > fqDependencies = new HashSet < > ( ) ; for ( Package pkg : prev . packages ( ) . values ( ) ) { if ( pkg . sources ( ) . isEmpty ( ) ) continue ; pkg . typeClasspathDependencies ( ) . values ( ) . forEach ( fqDependencies :: addAll ) ; } PubApiExtractor pubApiExtractor = new PubApiExtractor ( options ) ; Map < String , PubApi > onDiskPubApi = new HashMap < > ( ) ; for ( String cpDep : fqDependencies ) { onDiskPubApi . put ( cpDep , pubApiExtractor . getPubApi ( cpDep ) ) ; } pubApiExtractor . close ( ) ; nextPkg : for ( Package pkg : prev . packages ( ) . values ( ) ) { if ( pkg . sources ( ) . isEmpty ( ) ) continue ; Set < String > cpDepsOfThisPkg = new HashSet < > ( ) ; for ( Set < String > cpDeps : pkg . typeClasspathDependencies ( ) . values ( ) ) cpDepsOfThisPkg . addAll ( cpDeps ) ; for ( String fqDep : cpDepsOfThisPkg ) { String depPkg = ":" + fqDep . substring ( 0 , fqDep . lastIndexOf ( '.' ) ) ; PubApi prevPkgApi = prev . packages ( ) . get ( depPkg ) . getPubApi ( ) ; PubApi prevDepApi = prevPkgApi . types . get ( fqDep ) . pubApi ; PubApi currentDepApi = onDiskPubApi . get ( fqDep ) . types . get ( fqDep ) . pubApi ; if ( ! currentDepApi . isBackwardCompatibleWith ( prevDepApi ) ) { List < String > apiDiff = currentDepApi . diff ( prevDepApi ) ; taintPackage ( pkg . name ( ) , "depends on classpath " + "package which has an updated package api: " + String . join ( "\n" , apiDiff ) ) ; continue nextPkg ; } } } }
Compare the javac_state recorded public apis of packages on the classpath with the actual public apis on the classpath .
531
public void removeSuperfluousArtifacts ( Set < String > recentlyCompiled ) { if ( recentlyCompiled . size ( ) == 0 ) return ; for ( String pkg : now . packages ( ) . keySet ( ) ) { if ( ! recentlyCompiled . contains ( pkg ) ) continue ; Collection < File > arts = now . artifacts ( ) . values ( ) ; for ( File f : fetchPrevArtifacts ( pkg ) . values ( ) ) { if ( ! arts . contains ( f ) ) { Log . debug ( "Removing " + f . getPath ( ) + " since it is now superfluous!" ) ; if ( f . exists ( ) ) f . delete ( ) ; } } } }
Remove artifacts that are no longer produced when compiling!
532
private Set < Source > calculateRemovedSources ( ) { Set < Source > removed = new HashSet < > ( ) ; for ( String src : prev . sources ( ) . keySet ( ) ) { if ( now . sources ( ) . get ( src ) == null ) { removed . add ( prev . sources ( ) . get ( src ) ) ; } } return removed ; }
Return those files belonging to prev but not now .
533
private Set < Source > calculateAddedSources ( ) { Set < Source > added = new HashSet < > ( ) ; for ( String src : now . sources ( ) . keySet ( ) ) { if ( prev . sources ( ) . get ( src ) == null ) { added . add ( now . sources ( ) . get ( src ) ) ; } } return added ; }
Return those files belonging to now but not prev .
534
private Set < Source > calculateModifiedSources ( ) { Set < Source > modified = new HashSet < > ( ) ; for ( String src : now . sources ( ) . keySet ( ) ) { Source n = now . sources ( ) . get ( src ) ; Source t = prev . sources ( ) . get ( src ) ; if ( prev . sources ( ) . get ( src ) != null ) { if ( t != null ) { if ( n . lastModified ( ) > t . lastModified ( ) ) { modified . add ( n ) ; } else if ( n . lastModified ( ) < t . lastModified ( ) ) { modified . add ( n ) ; Log . warn ( "The source file " + n . name ( ) + " timestamp has moved backwards in time." ) ; } } } } return modified ; }
Return those files where the timestamp is newer . If a source file timestamp suddenly is older than what is known about it in javac_state then consider it modified but print a warning!
535
private static Set < File > findAllFiles ( File dir ) { Set < File > foundFiles = new HashSet < > ( ) ; if ( dir == null ) { return foundFiles ; } recurse ( dir , foundFiles ) ; return foundFiles ; }
Utility method to recursively find all files below a directory .
536
public void compareWithMakefileList ( File makefileSourceList ) throws ProblemException { boolean mightNeedRewriting = File . pathSeparatorChar == ';' ; if ( makefileSourceList == null ) return ; Set < String > calculatedSources = new HashSet < > ( ) ; Set < String > listedSources = new HashSet < > ( ) ; for ( Source s : now . sources ( ) . values ( ) ) { if ( ! s . isLinkedOnly ( ) ) { String path = s . file ( ) . getPath ( ) ; if ( mightNeedRewriting ) path = Util . normalizeDriveLetter ( path ) ; calculatedSources . add ( path ) ; } } try ( BufferedReader in = new BufferedReader ( new FileReader ( makefileSourceList ) ) ) { for ( ; ; ) { String l = in . readLine ( ) ; if ( l == null ) break ; l = l . trim ( ) ; if ( mightNeedRewriting ) { if ( l . indexOf ( ":" ) == 1 && l . indexOf ( "\\" ) == 2 ) { } else if ( l . indexOf ( ":" ) == 1 && l . indexOf ( "/" ) == 2 ) { l = l . replaceAll ( "/" , "\\\\" ) ; } else if ( l . charAt ( 0 ) == '/' && l . indexOf ( "/" , 1 ) != - 1 ) { int slash = l . indexOf ( "/" , 1 ) ; l = l . replaceAll ( "/" , "\\\\" ) ; l = "" + l . charAt ( slash + 1 ) + ":" + l . substring ( slash + 2 ) ; } if ( Character . isLowerCase ( l . charAt ( 0 ) ) ) { l = Character . toUpperCase ( l . charAt ( 0 ) ) + l . substring ( 1 ) ; } } listedSources . add ( l ) ; } } catch ( FileNotFoundException | NoSuchFileException e ) { throw new ProblemException ( "Could not open " + makefileSourceList . getPath ( ) + " since it does not exist!" ) ; } catch ( IOException e ) { throw new ProblemException ( "Could not read " + makefileSourceList . getPath ( ) ) ; } for ( String s : listedSources ) { if ( ! calculatedSources . contains ( s ) ) { throw new ProblemException ( "The makefile listed source " + s + " was not calculated by the smart javac wrapper!" ) ; } } for ( String s : calculatedSources ) { if ( ! listedSources . contains ( s ) ) { throw new ProblemException ( "The smart javac wrapper calculated source " + s + " was not listed by the makefiles!" ) ; } } }
Compare the calculate source list with an explicit list usually supplied from the makefile . Used to detect bugs where the makefile and sjavac have different opinions on which files should be compiled .
537
List < SnippetEvent > eval ( String userSource ) throws IllegalStateException { List < SnippetEvent > allEvents = new ArrayList < > ( ) ; for ( Snippet snip : sourceToSnippets ( userSource ) ) { if ( snip . kind ( ) == Kind . ERRONEOUS ) { state . maps . installSnippet ( snip ) ; allEvents . add ( new SnippetEvent ( snip , Status . NONEXISTENT , Status . REJECTED , false , null , null , null ) ) ; } else { allEvents . addAll ( declare ( snip , snip . syntheticDiags ( ) ) ) ; } } return allEvents ; }
Evaluates a snippet of source .
538
public JavaFileObject useSource ( JavaFileObject file ) { JavaFileObject prev = ( source == null ? null : source . getFile ( ) ) ; source = getSource ( file ) ; return prev ; }
Re - assign source returning previous setting .
539
public void mandatoryWarning ( LintCategory lc , DiagnosticPosition pos , Warning warningKey ) { report ( diags . mandatoryWarning ( lc , source , pos , warningKey ) ) ; }
Report a warning .
540
public ProgramElementDoc [ ] toProgramElementDocArray ( List < ProgramElementDoc > list ) { ProgramElementDoc [ ] pgmarr = new ProgramElementDoc [ list . size ( ) ] ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { pgmarr [ i ] = list . get ( i ) ; } return pgmarr ; }
Return the list of ProgramElementDoc objects as Array .
541
public String getPackageName ( PackageDoc packageDoc ) { return packageDoc == null || packageDoc . name ( ) . length ( ) == 0 ? DocletConstants . DEFAULT_PACKAGE_NAME : packageDoc . name ( ) ; }
Given a package return its name .
542
public String getPackageFileHeadName ( PackageDoc packageDoc ) { return packageDoc == null || packageDoc . name ( ) . length ( ) == 0 ? DocletConstants . DEFAULT_PACKAGE_FILE_NAME : packageDoc . name ( ) ; }
Given a package return its file name without the extension .
543
public String replaceTabs ( Configuration configuration , String text ) { if ( ! text . contains ( "\t" ) ) return text ; final int tabLength = configuration . sourcetab ; final String whitespace = configuration . tabSpaces ; final int textLength = text . length ( ) ; StringBuilder result = new StringBuilder ( textLength ) ; int pos = 0 ; int lineLength = 0 ; for ( int i = 0 ; i < textLength ; i ++ ) { char ch = text . charAt ( i ) ; switch ( ch ) { case '\n' : case '\r' : lineLength = 0 ; break ; case '\t' : result . append ( text , pos , i ) ; int spaceCount = tabLength - lineLength % tabLength ; result . append ( whitespace , 0 , spaceCount ) ; lineLength += spaceCount ; pos = i + 1 ; break ; default : lineLength ++ ; } } result . append ( text , pos , textLength ) ; return result . toString ( ) ; }
Replace all tabs in a string with the appropriate number of spaces . The string may be a multi - line string .
544
public Content getSerializableMethods ( String heading , Content serializableMethodContent ) { Content headingContent = new StringContent ( heading ) ; Content serialHeading = HtmlTree . HEADING ( HtmlConstants . SERIALIZED_MEMBER_HEADING , headingContent ) ; Content li = HtmlTree . LI ( HtmlStyle . blockList , serialHeading ) ; li . addContent ( serializableMethodContent ) ; return li ; }
Add serializable methods .
545
public boolean isExternal ( ProgramElementDoc doc ) { if ( packageToItemMap == null ) { return false ; } return packageToItemMap . get ( doc . containingPackage ( ) . name ( ) ) != null ; }
Determine if a doc item is externally documented .
546
public String typeName ( ) { return ( type instanceof ClassDoc || type instanceof TypeVariable ) ? type . typeName ( ) : type . toString ( ) ; }
Get type name of this parameter . For example if parameter is the short index returns short .
547
public AnnotationDesc [ ] annotations ( ) { AnnotationDesc res [ ] = new AnnotationDesc [ sym . getRawAttributes ( ) . length ( ) ] ; int i = 0 ; for ( Attribute . Compound a : sym . getRawAttributes ( ) ) { res [ i ++ ] = new AnnotationDescImpl ( env , a ) ; } return res ; }
Get the annotations of this parameter . Return an empty array if there are none .
548
protected static boolean isStatic ( Env < AttrContext > env ) { return env . outer != null && env . info . staticLevel > env . outer . info . staticLevel ; }
An environment is static if its static level is greater than the one of its outer environment
549
static boolean isInitializer ( Env < AttrContext > env ) { Symbol owner = env . info . scope . owner ; return owner . isConstructor ( ) || owner . owner . kind == TYP && ( owner . kind == VAR || owner . kind == MTH && ( owner . flags ( ) & BLOCK ) != 0 ) && ( owner . flags ( ) & STATIC ) == 0 ; }
An environment is an initializer if it is a constructor or an instance initializer .
550
public boolean isAccessible ( Env < AttrContext > env , TypeSymbol c ) { return isAccessible ( env , c , false ) ; }
Is class accessible in given evironment?
551
private boolean isInnerSubClass ( ClassSymbol c , Symbol base ) { while ( c != null && ! c . isSubClass ( base , types ) ) { c = c . owner . enclClass ( ) ; } return c != null ; }
Is given class a subclass of given base class or an inner class of a subclass? Return null if no such class exists .
552
public boolean isAccessible ( Env < AttrContext > env , Type site , Symbol sym ) { return isAccessible ( env , site , sym , false ) ; }
Is symbol accessible as a member of given type in given environment?
553
private boolean isProtectedAccessible ( Symbol sym , ClassSymbol c , Type site ) { Type newSite = site . hasTag ( TYPEVAR ) ? site . getUpperBound ( ) : site ; while ( c != null && ! ( c . isSubClass ( sym . owner , types ) && ( c . flags ( ) & INTERFACE ) == 0 && ( ( sym . flags ( ) & STATIC ) != 0 || sym . kind == TYP || newSite . tsym . isSubClass ( c , types ) ) ) ) c = c . owner . enclClass ( ) ; return c != null ; }
Is given protected symbol accessible if it is selected from given site and the selection takes place in given class?
554
void checkAccessibleType ( Env < AttrContext > env , Type t ) { accessibilityChecker . visit ( t , env ) ; }
Performs a recursive scan of a type looking for accessibility problems from current attribution environment
555
Type instantiate ( Env < AttrContext > env , Type site , Symbol m , ResultInfo resultInfo , List < Type > argtypes , List < Type > typeargtypes , boolean allowBoxing , boolean useVarargs , Warner warn ) { try { return rawInstantiate ( env , site , m , resultInfo , argtypes , typeargtypes , allowBoxing , useVarargs , warn ) ; } catch ( InapplicableMethodException ex ) { return null ; } }
Same but returns null instead throwing a NoInstanceException
556
Symbol findField ( Env < AttrContext > env , Type site , Name name , TypeSymbol c ) { while ( c . type . hasTag ( TYPEVAR ) ) c = c . type . getUpperBound ( ) . tsym ; Symbol bestSoFar = varNotFound ; Symbol sym ; for ( Symbol s : c . members ( ) . getSymbolsByName ( name ) ) { if ( s . kind == VAR && ( s . flags_field & SYNTHETIC ) == 0 ) { return isAccessible ( env , site , s ) ? s : new AccessError ( env , site , s ) ; } } Type st = types . supertype ( c . type ) ; if ( st != null && ( st . hasTag ( CLASS ) || st . hasTag ( TYPEVAR ) ) ) { sym = findField ( env , site , name , st . tsym ) ; bestSoFar = bestOf ( bestSoFar , sym ) ; } for ( List < Type > l = types . interfaces ( c . type ) ; bestSoFar . kind != AMBIGUOUS && l . nonEmpty ( ) ; l = l . tail ) { sym = findField ( env , site , name , l . head . tsym ) ; if ( bestSoFar . exists ( ) && sym . exists ( ) && sym . owner != bestSoFar . owner ) bestSoFar = new AmbiguityError ( bestSoFar , sym ) ; else bestSoFar = bestOf ( bestSoFar , sym ) ; } return bestSoFar ; }
Find field . Synthetic fields are always skipped .
557
public VarSymbol resolveInternalField ( DiagnosticPosition pos , Env < AttrContext > env , Type site , Name name ) { Symbol sym = findField ( env , site , name , site . tsym ) ; if ( sym . kind == VAR ) return ( VarSymbol ) sym ; else throw new FatalError ( diags . fragment ( "fatal.err.cant.locate.field" , name ) ) ; }
Resolve a field identifier throw a fatal error if not found .
558
Symbol findVar ( Env < AttrContext > env , Name name ) { Symbol bestSoFar = varNotFound ; Env < AttrContext > env1 = env ; boolean staticOnly = false ; while ( env1 . outer != null ) { Symbol sym = null ; if ( isStatic ( env1 ) ) staticOnly = true ; for ( Symbol s : env1 . info . scope . getSymbolsByName ( name ) ) { if ( s . kind == VAR && ( s . flags_field & SYNTHETIC ) == 0 ) { sym = s ; break ; } } if ( sym == null ) { sym = findField ( env1 , env1 . enclClass . sym . type , name , env1 . enclClass . sym ) ; } if ( sym . exists ( ) ) { if ( staticOnly && sym . kind == VAR && sym . owner . kind == TYP && ( sym . flags ( ) & STATIC ) == 0 ) return new StaticError ( sym ) ; else return sym ; } else { bestSoFar = bestOf ( bestSoFar , sym ) ; } if ( ( env1 . enclClass . sym . flags ( ) & STATIC ) != 0 ) staticOnly = true ; env1 = env1 . outer ; } Symbol sym = findField ( env , syms . predefClass . type , name , syms . predefClass ) ; if ( sym . exists ( ) ) return sym ; if ( bestSoFar . exists ( ) ) return bestSoFar ; Symbol origin = null ; for ( Scope sc : new Scope [ ] { env . toplevel . namedImportScope , env . toplevel . starImportScope } ) { for ( Symbol currentSymbol : sc . getSymbolsByName ( name ) ) { if ( currentSymbol . kind != VAR ) continue ; if ( ! bestSoFar . kind . isResolutionError ( ) && currentSymbol . owner != bestSoFar . owner ) return new AmbiguityError ( bestSoFar , currentSymbol ) ; else if ( ! bestSoFar . kind . betterThan ( VAR ) ) { origin = sc . getOrigin ( currentSymbol ) . owner ; bestSoFar = isAccessible ( env , origin . type , currentSymbol ) ? currentSymbol : new AccessError ( env , origin . type , currentSymbol ) ; } } if ( bestSoFar . exists ( ) ) break ; } if ( bestSoFar . kind == VAR && bestSoFar . owner . type != origin . type ) return bestSoFar . clone ( origin ) ; else return bestSoFar ; }
Find unqualified variable or field with given name . Synthetic fields always skipped .
559
Symbol findInheritedMemberType ( Env < AttrContext > env , Type site , Name name , TypeSymbol c ) { Symbol bestSoFar = typeNotFound ; Symbol sym ; Type st = types . supertype ( c . type ) ; if ( st != null && st . hasTag ( CLASS ) ) { sym = findMemberType ( env , site , name , st . tsym ) ; bestSoFar = bestOf ( bestSoFar , sym ) ; } for ( List < Type > l = types . interfaces ( c . type ) ; bestSoFar . kind != AMBIGUOUS && l . nonEmpty ( ) ; l = l . tail ) { sym = findMemberType ( env , site , name , l . head . tsym ) ; if ( ! bestSoFar . kind . isResolutionError ( ) && ! sym . kind . isResolutionError ( ) && sym . owner != bestSoFar . owner ) bestSoFar = new AmbiguityError ( bestSoFar , sym ) ; else bestSoFar = bestOf ( bestSoFar , sym ) ; } return bestSoFar ; }
Find a member type inherited from a superclass or interface .
560
Symbol findMemberType ( Env < AttrContext > env , Type site , Name name , TypeSymbol c ) { Symbol sym = findImmediateMemberType ( env , site , name , c ) ; if ( sym != typeNotFound ) return sym ; return findInheritedMemberType ( env , site , name , c ) ; }
Find qualified member type .
561
Symbol findType ( Env < AttrContext > env , Name name ) { if ( name == names . empty ) return typeNotFound ; Symbol bestSoFar = typeNotFound ; Symbol sym ; boolean staticOnly = false ; for ( Env < AttrContext > env1 = env ; env1 . outer != null ; env1 = env1 . outer ) { if ( isStatic ( env1 ) ) staticOnly = true ; final Symbol tyvar = findTypeVar ( env1 , name , staticOnly ) ; sym = findImmediateMemberType ( env1 , env1 . enclClass . sym . type , name , env1 . enclClass . sym ) ; if ( tyvar != typeNotFound ) { if ( env . baseClause || sym == typeNotFound || ( tyvar . kind == TYP && tyvar . exists ( ) && tyvar . owner . kind == MTH ) ) { return tyvar ; } } if ( sym == typeNotFound ) sym = findInheritedMemberType ( env1 , env1 . enclClass . sym . type , name , env1 . enclClass . sym ) ; if ( staticOnly && sym . kind == TYP && sym . type . hasTag ( CLASS ) && sym . type . getEnclosingType ( ) . hasTag ( CLASS ) && env1 . enclClass . sym . type . isParameterized ( ) && sym . type . getEnclosingType ( ) . isParameterized ( ) ) return new StaticError ( sym ) ; else if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; JCClassDecl encl = env1 . baseClause ? ( JCClassDecl ) env1 . tree : env1 . enclClass ; if ( ( encl . sym . flags ( ) & STATIC ) != 0 ) staticOnly = true ; } if ( ! env . tree . hasTag ( IMPORT ) ) { sym = findGlobalType ( env , env . toplevel . namedImportScope , name , namedImportScopeRecovery ) ; if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; sym = findGlobalType ( env , env . toplevel . packge . members ( ) , name , noRecovery ) ; if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; sym = findGlobalType ( env , env . toplevel . starImportScope , name , starImportScopeRecovery ) ; if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; } return bestSoFar ; }
Find an unqualified type symbol .
562
Symbol accessMethod ( Symbol sym , DiagnosticPosition pos , Symbol location , Type site , Name name , boolean qualified , List < Type > argtypes , List < Type > typeargtypes ) { return accessInternal ( sym , pos , location , site , name , qualified , argtypes , typeargtypes , methodLogResolveHelper ) ; }
Variant of the generalized access routine to be used for generating method resolution diagnostics
563
Symbol accessBase ( Symbol sym , DiagnosticPosition pos , Symbol location , Type site , Name name , boolean qualified ) { return accessInternal ( sym , pos , location , site , name , qualified , List . nil ( ) , null , basicLogResolveHelper ) ; }
Variant of the generalized access routine to be used for generating variable type resolution diagnostics
564
void checkNonAbstract ( DiagnosticPosition pos , Symbol sym ) { if ( ( sym . flags ( ) & ABSTRACT ) != 0 && ( sym . flags ( ) & DEFAULT ) == 0 ) log . error ( pos , "abstract.cant.be.accessed.directly" , kindName ( sym ) , sym , sym . location ( ) ) ; }
Check that sym is not an abstract method .
565
Symbol resolveQualifiedMethod ( DiagnosticPosition pos , Env < AttrContext > env , Type site , Name name , List < Type > argtypes , List < Type > typeargtypes ) { return resolveQualifiedMethod ( pos , env , site . tsym , site , name , argtypes , typeargtypes ) ; }
Resolve a qualified method identifier
566
public MethodSymbol resolveInternalMethod ( DiagnosticPosition pos , Env < AttrContext > env , Type site , Name name , List < Type > argtypes , List < Type > typeargtypes ) { MethodResolutionContext resolveContext = new MethodResolutionContext ( ) ; resolveContext . internalResolution = true ; Symbol sym = resolveQualifiedMethod ( resolveContext , pos , env , site . tsym , site , name , argtypes , typeargtypes ) ; if ( sym . kind == MTH ) return ( MethodSymbol ) sym ; else throw new FatalError ( diags . fragment ( "fatal.err.cant.locate.meth" , name ) ) ; }
Resolve a qualified method identifier throw a fatal error if not found .
567
Symbol resolveConstructor ( DiagnosticPosition pos , Env < AttrContext > env , Type site , List < Type > argtypes , List < Type > typeargtypes ) { return resolveConstructor ( new MethodResolutionContext ( ) , pos , env , site , argtypes , typeargtypes ) ; }
Resolve constructor .
568
public MethodSymbol resolveInternalConstructor ( DiagnosticPosition pos , Env < AttrContext > env , Type site , List < Type > argtypes , List < Type > typeargtypes ) { MethodResolutionContext resolveContext = new MethodResolutionContext ( ) ; resolveContext . internalResolution = true ; Symbol sym = resolveConstructor ( resolveContext , pos , env , site , argtypes , typeargtypes ) ; if ( sym . kind == MTH ) return ( MethodSymbol ) sym ; else throw new FatalError ( diags . fragment ( "fatal.err.cant.locate.ctor" , site ) ) ; }
Resolve a constructor throw a fatal error if not found .
569
Symbol resolveSelf ( DiagnosticPosition pos , Env < AttrContext > env , TypeSymbol c , Name name ) { Env < AttrContext > env1 = env ; boolean staticOnly = false ; while ( env1 . outer != null ) { if ( isStatic ( env1 ) ) staticOnly = true ; if ( env1 . enclClass . sym == c ) { Symbol sym = env1 . info . scope . findFirst ( name ) ; if ( sym != null ) { if ( staticOnly ) sym = new StaticError ( sym ) ; return accessBase ( sym , pos , env . enclClass . sym . type , name , true ) ; } } if ( ( env1 . enclClass . sym . flags ( ) & STATIC ) != 0 ) staticOnly = true ; env1 = env1 . outer ; } if ( c . isInterface ( ) && name == names . _super && ! isStatic ( env ) && types . isDirectSuperInterface ( c , env . enclClass . sym ) ) { for ( Type t : pruneInterfaces ( env . enclClass . type ) ) { if ( t . tsym == c ) { env . info . defaultSuperCallSite = t ; return new VarSymbol ( 0 , names . _super , types . asSuper ( env . enclClass . type , c ) , env . enclClass . sym ) ; } } for ( Type i : types . directSupertypes ( env . enclClass . type ) ) { if ( i . tsym . isSubClass ( c , types ) && i . tsym != c ) { log . error ( pos , "illegal.default.super.call" , c , diags . fragment ( "redundant.supertype" , c , i ) ) ; return syms . errSymbol ; } } Assert . error ( ) ; } log . error ( pos , "not.encl.class" , c ) ; return syms . errSymbol ; }
Resolve c . name where name == this or name == super .
570
Symbol resolveSelfContaining ( DiagnosticPosition pos , Env < AttrContext > env , Symbol member , boolean isSuperCall ) { Symbol sym = resolveSelfContainingInternal ( env , member , isSuperCall ) ; if ( sym == null ) { log . error ( pos , "encl.class.required" , member ) ; return syms . errSymbol ; } else { return accessBase ( sym , pos , env . enclClass . sym . type , sym . name , true ) ; } }
Resolve c . this for an enclosing class c that contains the named member .
571
Type resolveImplicitThis ( DiagnosticPosition pos , Env < AttrContext > env , Type t ) { return resolveImplicitThis ( pos , env , t , false ) ; }
Resolve an appropriate implicit this instance for t s container . JLS 8 . 8 . 5 . 1 and 15 . 9 . 2
572
public void logAccessErrorInternal ( Env < AttrContext > env , JCTree tree , Type type ) { AccessError error = new AccessError ( env , env . enclClass . type , type . tsym ) ; logResolveError ( error , tree . pos ( ) , env . enclClass . sym , env . enclClass . type , null , null , null ) ; }
used by TransTypes when checking target type of synthetic cast
573
public List < ProgramElementDoc > getLeafClassMembers ( Configuration configuration ) { List < ProgramElementDoc > result = getMembersFor ( classdoc ) ; result . addAll ( getInheritedPackagePrivateMethods ( configuration ) ) ; return result ; }
Return the visible members of the class being mapped . Also append at the end of the list members that are inherited by inaccessible parents . We document these members in the child because the parent is not documented .
574
public List < ProgramElementDoc > getMembersFor ( ClassDoc cd ) { ClassMembers clmembers = classMap . get ( cd ) ; if ( clmembers == null ) { return new ArrayList < > ( ) ; } return clmembers . getMembers ( ) ; }
Retrn the list of members for the given class .
575
public DocLink getDocLink ( SectionName sectionName , String where ) { return DocLink . fragment ( sectionName . getName ( ) + getName ( where ) ) ; }
Get the link .
576
public String getName ( String name ) { StringBuilder sb = new StringBuilder ( ) ; char ch ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { ch = name . charAt ( i ) ; switch ( ch ) { case '(' : case ')' : case '<' : case '>' : case ',' : sb . append ( '-' ) ; break ; case ' ' : case '[' : break ; case ']' : sb . append ( ":A" ) ; break ; case '$' : if ( i == 0 ) sb . append ( "Z:Z" ) ; sb . append ( ":D" ) ; break ; case '_' : if ( i == 0 ) sb . append ( "Z:Z" ) ; sb . append ( ch ) ; break ; default : sb . append ( ch ) ; } } return sb . toString ( ) ; }
Convert the name to a valid HTML name .
577
public String getPkgName ( ClassDoc cd ) { String pkgName = cd . containingPackage ( ) . name ( ) ; if ( pkgName . length ( ) > 0 ) { pkgName += "." ; return pkgName ; } return "" ; }
Get the name of the package this class is in .
578
public void printFramesDocument ( String title , ConfigurationImpl configuration , HtmlTree body ) throws IOException { Content htmlDocType = configuration . isOutputHtml5 ( ) ? DocType . HTML5 : DocType . TRANSITIONAL ; Content htmlComment = new Comment ( configuration . getText ( "doclet.New_Page" ) ) ; Content head = new HtmlTree ( HtmlTag . HEAD ) ; head . addContent ( getGeneratedBy ( ! configuration . notimestamp ) ) ; Content windowTitle = HtmlTree . TITLE ( new StringContent ( title ) ) ; head . addContent ( windowTitle ) ; Content meta = HtmlTree . META ( "Content-Type" , CONTENT_TYPE , ( configuration . charset . length ( ) > 0 ) ? configuration . charset : HtmlConstants . HTML_DEFAULT_CHARSET ) ; head . addContent ( meta ) ; head . addContent ( getStyleSheetProperties ( configuration ) ) ; head . addContent ( getFramesJavaScript ( ) ) ; Content htmlTree = HtmlTree . HTML ( configuration . getLocale ( ) . getLanguage ( ) , head , body ) ; Content htmlDocument = new HtmlDocument ( htmlDocType , htmlComment , htmlTree ) ; write ( htmlDocument ) ; }
Print the frames version of the Html file header . Called only when generating an HTML frames file .
579
public static RichDiagnosticFormatter instance ( Context context ) { RichDiagnosticFormatter instance = context . get ( RichDiagnosticFormatter . class ) ; if ( instance == null ) instance = new RichDiagnosticFormatter ( context ) ; return instance ; }
Get the DiagnosticFormatter instance for this context .
580
protected List < JCDiagnostic > getWhereClauses ( ) { List < JCDiagnostic > clauses = List . nil ( ) ; for ( WhereClauseKind kind : WhereClauseKind . values ( ) ) { List < JCDiagnostic > lines = List . nil ( ) ; for ( Map . Entry < Type , JCDiagnostic > entry : whereClauses . get ( kind ) . entrySet ( ) ) { lines = lines . prepend ( entry . getValue ( ) ) ; } if ( ! lines . isEmpty ( ) ) { String key = kind . key ( ) ; if ( lines . size ( ) > 1 ) key += ".1" ; JCDiagnostic d = diags . fragment ( key , whereClauses . get ( kind ) . keySet ( ) ) ; d = new JCDiagnostic . MultilineDiagnostic ( d , lines . reverse ( ) ) ; clauses = clauses . prepend ( d ) ; } } return clauses . reverse ( ) ; }
Build a list of multiline diagnostics containing detailed info about type - variables captured types and intersection types
581
protected HtmlTree getTreeHeader ( ) { String title = configuration . getText ( "doclet.Window_Class_Hierarchy" ) ; 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 ) ; } return bodyTree ; }
Get the tree header .
582
public JCCompilationUnit parseCompilationUnit ( ) { Token firstToken = token ; JCModifiers mods = null ; boolean seenImport = false ; boolean seenPackage = false ; ListBuffer < JCTree > defs = new ListBuffer < > ( ) ; if ( token . kind == MONKEYS_AT ) { mods = modifiersOpt ( ) ; } boolean firstTypeDecl = true ; while ( token . kind != EOF ) { if ( token . pos > 0 && token . pos <= endPosTable . errorEndPos ) { skip ( true , false , false , false ) ; if ( token . kind == EOF ) { break ; } } if ( mods == null && token . kind == IMPORT ) { seenImport = true ; defs . append ( importDeclaration ( ) ) ; } else { Comment docComment = token . comment ( CommentStyle . JAVADOC ) ; if ( firstTypeDecl && ! seenImport && ! seenPackage ) { docComment = firstToken . comment ( CommentStyle . JAVADOC ) ; } List < ? extends JCTree > udefs = replUnit ( mods , docComment ) ; for ( JCTree def : udefs ) { defs . append ( def ) ; } mods = null ; firstTypeDecl = false ; } break ; } List < JCTree > rdefs = defs . toList ( ) ; class ReplUnit extends JCCompilationUnit { public ReplUnit ( List < JCTree > defs ) { super ( defs ) ; } } JCCompilationUnit toplevel = new ReplUnit ( rdefs ) ; if ( rdefs . isEmpty ( ) ) { storeEnd ( toplevel , S . prevToken ( ) . endPos ) ; } toplevel . lineMap = S . getLineMap ( ) ; this . endPosTable . setParser ( null ) ; toplevel . endPositions = this . endPosTable ; return toplevel ; }
As faithful a clone of the overridden method as possible while still achieving the goal of allowing the parse of a stand - alone snippet . As a result some variables are assigned and never used tests are always true loops don t etc . This is to allow easy transition as the underlying method changes .
583
protected void addPartialInfo ( ClassDoc cd , Content contentTree ) { addPreQualifiedStrongClassLink ( LinkInfoImpl . Kind . TREE , cd , contentTree ) ; }
Add information about the class kind if it s a class or interface .
584
protected Content getNavLinkTree ( ) { Content li = HtmlTree . LI ( HtmlStyle . navBarCell1Rev , treeLabel ) ; return li ; }
Get the tree label for the navigation bar .
585
private void enterMember ( ClassSymbol c , Symbol sym ) { if ( ( sym . flags_field & ( SYNTHETIC | BRIDGE ) ) != SYNTHETIC || sym . name . startsWith ( names . lambda ) ) c . members_field . enter ( sym ) ; }
Add member to class unless it is synthetic .
586
int getInt ( int bp ) { return ( ( buf [ bp ] & 0xFF ) << 24 ) + ( ( buf [ bp + 1 ] & 0xFF ) << 16 ) + ( ( buf [ bp + 2 ] & 0xFF ) << 8 ) + ( buf [ bp + 3 ] & 0xFF ) ; }
Extract an integer at position bp from buf .
587
long getLong ( int bp ) { DataInputStream bufin = new DataInputStream ( new ByteArrayInputStream ( buf , bp , 8 ) ) ; try { return bufin . readLong ( ) ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } }
Extract a long integer at position bp from buf .
588
float getFloat ( int bp ) { DataInputStream bufin = new DataInputStream ( new ByteArrayInputStream ( buf , bp , 4 ) ) ; try { return bufin . readFloat ( ) ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } }
Extract a float at position bp from buf .
589
double getDouble ( int bp ) { DataInputStream bufin = new DataInputStream ( new ByteArrayInputStream ( buf , bp , 8 ) ) ; try { return bufin . readDouble ( ) ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } }
Extract a double at position bp from buf .
590
Object readPool ( int i ) { Object result = poolObj [ i ] ; if ( result != null ) return result ; int index = poolIdx [ i ] ; if ( index == 0 ) return null ; byte tag = buf [ index ] ; switch ( tag ) { case CONSTANT_Utf8 : poolObj [ i ] = names . fromUtf ( buf , index + 3 , getChar ( index + 1 ) ) ; break ; case CONSTANT_Unicode : throw badClassFile ( "unicode.str.not.supported" ) ; case CONSTANT_Class : poolObj [ i ] = readClassOrType ( getChar ( index + 1 ) ) ; break ; case CONSTANT_String : poolObj [ i ] = readName ( getChar ( index + 1 ) ) . toString ( ) ; break ; case CONSTANT_Fieldref : { ClassSymbol owner = readClassSymbol ( getChar ( index + 1 ) ) ; NameAndType nt = readNameAndType ( getChar ( index + 3 ) ) ; poolObj [ i ] = new VarSymbol ( 0 , nt . name , nt . uniqueType . type , owner ) ; break ; } case CONSTANT_Methodref : case CONSTANT_InterfaceMethodref : { ClassSymbol owner = readClassSymbol ( getChar ( index + 1 ) ) ; NameAndType nt = readNameAndType ( getChar ( index + 3 ) ) ; poolObj [ i ] = new MethodSymbol ( 0 , nt . name , nt . uniqueType . type , owner ) ; break ; } case CONSTANT_NameandType : poolObj [ i ] = new NameAndType ( readName ( getChar ( index + 1 ) ) , readType ( getChar ( index + 3 ) ) , types ) ; break ; case CONSTANT_Integer : poolObj [ i ] = getInt ( index + 1 ) ; break ; case CONSTANT_Float : poolObj [ i ] = Float . valueOf ( getFloat ( index + 1 ) ) ; break ; case CONSTANT_Long : poolObj [ i ] = Long . valueOf ( getLong ( index + 1 ) ) ; break ; case CONSTANT_Double : poolObj [ i ] = Double . valueOf ( getDouble ( index + 1 ) ) ; break ; case CONSTANT_MethodHandle : skipBytes ( 4 ) ; break ; case CONSTANT_MethodType : skipBytes ( 3 ) ; break ; case CONSTANT_InvokeDynamic : skipBytes ( 5 ) ; break ; case CONSTANT_Module : case CONSTANT_Package : poolObj [ i ] = readName ( getChar ( index + 1 ) ) ; break ; default : throw badClassFile ( "bad.const.pool.tag" , Byte . toString ( tag ) ) ; } return poolObj [ i ] ; }
Read constant pool entry at start address i use pool as a cache .
591
Type readType ( int i ) { int index = poolIdx [ i ] ; return sigToType ( buf , index + 3 , getChar ( index + 1 ) ) ; }
Read signature and convert to type .
592
Object readClassOrType ( int i ) { int index = poolIdx [ i ] ; int len = getChar ( index + 1 ) ; int start = index + 3 ; Assert . check ( buf [ start ] == '[' || buf [ start + len - 1 ] != ';' ) ; return ( buf [ start ] == '[' || buf [ start + len - 1 ] == ';' ) ? ( Object ) sigToType ( buf , start , len ) : ( Object ) enterClass ( names . fromUtf ( internalize ( buf , start , len ) ) ) ; }
If name is an array type or class signature return the corresponding type ; otherwise return a ClassSymbol with given name .
593
List < Type > readTypeParams ( int i ) { int index = poolIdx [ i ] ; return sigToTypeParams ( buf , index + 3 , getChar ( index + 1 ) ) ; }
Read signature and convert to type parameters .
594
ClassSymbol readClassSymbol ( int i ) { Object obj = readPool ( i ) ; if ( obj != null && ! ( obj instanceof ClassSymbol ) ) throw badClassFile ( "bad.const.pool.entry" , currentClassFile . toString ( ) , "CONSTANT_Class_info" , i ) ; return ( ClassSymbol ) obj ; }
Read class entry .
595
Name readName ( int i ) { Object obj = readPool ( i ) ; if ( obj != null && ! ( obj instanceof Name ) ) throw badClassFile ( "bad.const.pool.entry" , currentClassFile . toString ( ) , "CONSTANT_Utf8_info or CONSTANT_String_info" , i ) ; return ( Name ) obj ; }
Read name .
596
NameAndType readNameAndType ( int i ) { Object obj = readPool ( i ) ; if ( obj != null && ! ( obj instanceof NameAndType ) ) throw badClassFile ( "bad.const.pool.entry" , currentClassFile . toString ( ) , "CONSTANT_NameAndType_info" , i ) ; return ( NameAndType ) obj ; }
Read name and type .
597
Set < ModuleFlags > readModuleFlags ( int flags ) { Set < ModuleFlags > set = EnumSet . noneOf ( ModuleFlags . class ) ; for ( ModuleFlags f : ModuleFlags . values ( ) ) { if ( ( flags & f . value ) != 0 ) set . add ( f ) ; } return set ; }
Read module_flags .
598
Set < ModuleResolutionFlags > readModuleResolutionFlags ( int flags ) { Set < ModuleResolutionFlags > set = EnumSet . noneOf ( ModuleResolutionFlags . class ) ; for ( ModuleResolutionFlags f : ModuleResolutionFlags . values ( ) ) { if ( ( flags & f . value ) != 0 ) set . add ( f ) ; } return set ; }
Read resolution_flags .
599
Set < ExportsFlag > readExportsFlags ( int flags ) { Set < ExportsFlag > set = EnumSet . noneOf ( ExportsFlag . class ) ; for ( ExportsFlag f : ExportsFlag . values ( ) ) { if ( ( flags & f . value ) != 0 ) set . add ( f ) ; } return set ; }
Read exports_flags .