idx
int64 0
165k
| question
stringlengths 73
4.15k
| target
stringlengths 5
918
| len_question
int64 21
890
| len_target
int64 3
255
|
|---|---|---|---|---|
156,400
|
public boolean checkAndReturn ( ) { // Check if any thread has been interrupted if ( interrupted . get ( ) ) { // If so, interrupt this thread interrupt ( ) ; return true ; } // Check if this thread has been interrupted if ( Thread . currentThread ( ) . isInterrupted ( ) ) { // If so, interrupt other threads interrupted . set ( true ) ; return true ; } return false ; }
|
Check for interruption and return interruption status .
| 86
| 8
|
156,401
|
public void check ( ) throws InterruptedException , ExecutionException { // If a thread threw an uncaught exception, re-throw it. final ExecutionException executionException = getExecutionException ( ) ; if ( executionException != null ) { throw executionException ; } // If this thread or another thread has been interrupted, throw InterruptedException if ( checkAndReturn ( ) ) { throw new InterruptedException ( ) ; } }
|
Check if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception and if so throw InterruptedException .
| 88
| 32
|
156,402
|
public boolean isSystemModule ( ) { if ( name == null || name . isEmpty ( ) ) { return false ; } return name . startsWith ( "java." ) || name . startsWith ( "jdk." ) || name . startsWith ( "javafx." ) || name . startsWith ( "oracle." ) ; }
|
Checks if this module is a system module .
| 73
| 10
|
156,403
|
static MethodTypeSignature parse ( final String typeDescriptor , final String definingClassName ) throws ParseException { if ( typeDescriptor . equals ( "<init>" ) ) { // Special case for instance initialization method signatures in a CONSTANT_NameAndType_info structure: // https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.4.2 return new MethodTypeSignature ( Collections . < TypeParameter > emptyList ( ) , Collections . < TypeSignature > emptyList ( ) , new BaseTypeSignature ( "void" ) , Collections . < ClassRefOrTypeVariableSignature > emptyList ( ) ) ; } final Parser parser = new Parser ( typeDescriptor ) ; final List < TypeParameter > typeParameters = TypeParameter . parseList ( parser , definingClassName ) ; parser . expect ( ' ' ) ; final List < TypeSignature > paramTypes = new ArrayList <> ( ) ; while ( parser . peek ( ) != ' ' ) { if ( ! parser . hasMore ( ) ) { throw new ParseException ( parser , "Ran out of input while parsing method signature" ) ; } final TypeSignature paramType = TypeSignature . parse ( parser , definingClassName ) ; if ( paramType == null ) { throw new ParseException ( parser , "Missing method parameter type signature" ) ; } paramTypes . add ( paramType ) ; } parser . expect ( ' ' ) ; final TypeSignature resultType = TypeSignature . parse ( parser , definingClassName ) ; if ( resultType == null ) { throw new ParseException ( parser , "Missing method result type signature" ) ; } List < ClassRefOrTypeVariableSignature > throwsSignatures ; if ( parser . peek ( ) == ' ' ) { throwsSignatures = new ArrayList <> ( ) ; while ( parser . peek ( ) == ' ' ) { parser . expect ( ' ' ) ; final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature . parse ( parser , definingClassName ) ; if ( classTypeSignature != null ) { throwsSignatures . add ( classTypeSignature ) ; } else { final TypeVariableSignature typeVariableSignature = TypeVariableSignature . parse ( parser , definingClassName ) ; if ( typeVariableSignature != null ) { throwsSignatures . add ( typeVariableSignature ) ; } else { throw new ParseException ( parser , "Missing type variable signature" ) ; } } } } else { throwsSignatures = Collections . emptyList ( ) ; } if ( parser . hasMore ( ) ) { throw new ParseException ( parser , "Extra characters at end of type descriptor" ) ; } final MethodTypeSignature methodSignature = new MethodTypeSignature ( typeParameters , paramTypes , resultType , throwsSignatures ) ; // Add back-links from type variable signature to the method signature it is part of, // and to the enclosing class' type signature @ SuppressWarnings ( "unchecked" ) final List < TypeVariableSignature > typeVariableSignatures = ( List < TypeVariableSignature > ) parser . getState ( ) ; if ( typeVariableSignatures != null ) { for ( final TypeVariableSignature typeVariableSignature : typeVariableSignatures ) { typeVariableSignature . containingMethodSignature = methodSignature ; } } return methodSignature ; }
|
Parse a method signature .
| 750
| 6
|
156,404
|
void toJSONString ( final Map < ReferenceEqualityKey < JSONReference > , CharSequence > jsonReferenceToId , final boolean includeNullValuedFields , final int depth , final int indentWidth , final StringBuilder buf ) { final boolean prettyPrint = indentWidth > 0 ; final int n = items . size ( ) ; if ( n == 0 ) { buf . append ( "[]" ) ; } else { buf . append ( ' ' ) ; if ( prettyPrint ) { buf . append ( ' ' ) ; } for ( int i = 0 ; i < n ; i ++ ) { final Object item = items . get ( i ) ; if ( prettyPrint ) { JSONUtils . indent ( depth + 1 , indentWidth , buf ) ; } JSONSerializer . jsonValToJSONString ( item , jsonReferenceToId , includeNullValuedFields , depth + 1 , indentWidth , buf ) ; if ( i < n - 1 ) { buf . append ( ' ' ) ; } if ( prettyPrint ) { buf . append ( ' ' ) ; } } if ( prettyPrint ) { JSONUtils . indent ( depth , indentWidth , buf ) ; } buf . append ( ' ' ) ; } }
|
Serialize this JSONArray to a string .
| 259
| 9
|
156,405
|
boolean addRelatedClass ( final RelType relType , final ClassInfo classInfo ) { Set < ClassInfo > classInfoSet = relatedClasses . get ( relType ) ; if ( classInfoSet == null ) { relatedClasses . put ( relType , classInfoSet = new LinkedHashSet <> ( 4 ) ) ; } return classInfoSet . add ( classInfo ) ; }
|
Add a class with a given relationship type . Return whether the collection changed as a result of the call .
| 85
| 21
|
156,406
|
static ClassInfo getOrCreateClassInfo ( final String className , final int classModifiers , final Map < String , ClassInfo > classNameToClassInfo ) { ClassInfo classInfo = classNameToClassInfo . get ( className ) ; if ( classInfo == null ) { classNameToClassInfo . put ( className , classInfo = new ClassInfo ( className , classModifiers , /* classfileResource = */ null ) ) ; } classInfo . setModifiers ( classModifiers ) ; return classInfo ; }
|
Get a ClassInfo object or create it if it doesn t exist . N . B . not threadsafe so ClassInfo objects should only ever be constructed by a single thread .
| 113
| 35
|
156,407
|
void setModifiers ( final int modifiers ) { this . modifiers |= modifiers ; if ( ( modifiers & ANNOTATION_CLASS_MODIFIER ) != 0 ) { this . isAnnotation = true ; } if ( ( modifiers & Modifier . INTERFACE ) != 0 ) { this . isInterface = true ; } }
|
Set class modifiers .
| 69
| 4
|
156,408
|
void addSuperclass ( final String superclassName , final Map < String , ClassInfo > classNameToClassInfo ) { if ( superclassName != null && ! superclassName . equals ( "java.lang.Object" ) ) { final ClassInfo superclassClassInfo = getOrCreateClassInfo ( superclassName , /* classModifiers = */ 0 , classNameToClassInfo ) ; this . addRelatedClass ( RelType . SUPERCLASSES , superclassClassInfo ) ; superclassClassInfo . addRelatedClass ( RelType . SUBCLASSES , this ) ; } }
|
Add a superclass to this class .
| 126
| 8
|
156,409
|
void addImplementedInterface ( final String interfaceName , final Map < String , ClassInfo > classNameToClassInfo ) { final ClassInfo interfaceClassInfo = getOrCreateClassInfo ( interfaceName , /* classModifiers = */ Modifier . INTERFACE , classNameToClassInfo ) ; interfaceClassInfo . isInterface = true ; interfaceClassInfo . modifiers |= Modifier . INTERFACE ; this . addRelatedClass ( RelType . IMPLEMENTED_INTERFACES , interfaceClassInfo ) ; interfaceClassInfo . addRelatedClass ( RelType . CLASSES_IMPLEMENTING , this ) ; }
|
Add an implemented interface to this class .
| 131
| 8
|
156,410
|
static void addClassContainment ( final List < SimpleEntry < String , String > > classContainmentEntries , final Map < String , ClassInfo > classNameToClassInfo ) { for ( final SimpleEntry < String , String > ent : classContainmentEntries ) { final String innerClassName = ent . getKey ( ) ; final ClassInfo innerClassInfo = ClassInfo . getOrCreateClassInfo ( innerClassName , /* classModifiers = */ 0 , classNameToClassInfo ) ; final String outerClassName = ent . getValue ( ) ; final ClassInfo outerClassInfo = ClassInfo . getOrCreateClassInfo ( outerClassName , /* classModifiers = */ 0 , classNameToClassInfo ) ; innerClassInfo . addRelatedClass ( RelType . CONTAINED_WITHIN_OUTER_CLASS , outerClassInfo ) ; outerClassInfo . addRelatedClass ( RelType . CONTAINS_INNER_CLASS , innerClassInfo ) ; } }
|
Add class containment info .
| 210
| 5
|
156,411
|
void addClassAnnotation ( final AnnotationInfo classAnnotationInfo , final Map < String , ClassInfo > classNameToClassInfo ) { final ClassInfo annotationClassInfo = getOrCreateClassInfo ( classAnnotationInfo . getName ( ) , ANNOTATION_CLASS_MODIFIER , classNameToClassInfo ) ; if ( this . annotationInfo == null ) { this . annotationInfo = new AnnotationInfoList ( 2 ) ; } this . annotationInfo . add ( classAnnotationInfo ) ; this . addRelatedClass ( RelType . CLASS_ANNOTATIONS , annotationClassInfo ) ; annotationClassInfo . addRelatedClass ( RelType . CLASSES_WITH_ANNOTATION , this ) ; // Record use of @Inherited meta-annotation if ( classAnnotationInfo . getName ( ) . equals ( Inherited . class . getName ( ) ) ) { isInherited = true ; } }
|
Add an annotation to this class .
| 199
| 7
|
156,412
|
private void addFieldOrMethodAnnotationInfo ( final AnnotationInfoList annotationInfoList , final boolean isField , final Map < String , ClassInfo > classNameToClassInfo ) { if ( annotationInfoList != null ) { for ( final AnnotationInfo fieldAnnotationInfo : annotationInfoList ) { final ClassInfo annotationClassInfo = getOrCreateClassInfo ( fieldAnnotationInfo . getName ( ) , ANNOTATION_CLASS_MODIFIER , classNameToClassInfo ) ; // Mark this class as having a field or method with this annotation this . addRelatedClass ( isField ? RelType . FIELD_ANNOTATIONS : RelType . METHOD_ANNOTATIONS , annotationClassInfo ) ; annotationClassInfo . addRelatedClass ( isField ? RelType . CLASSES_WITH_FIELD_ANNOTATION : RelType . CLASSES_WITH_METHOD_ANNOTATION , this ) ; } } }
|
Add field or method annotation cross - links .
| 198
| 9
|
156,413
|
void addFieldInfo ( final FieldInfoList fieldInfoList , final Map < String , ClassInfo > classNameToClassInfo ) { for ( final FieldInfo fi : fieldInfoList ) { // Index field annotations addFieldOrMethodAnnotationInfo ( fi . annotationInfo , /* isField = */ true , classNameToClassInfo ) ; } if ( this . fieldInfo == null ) { this . fieldInfo = fieldInfoList ; } else { this . fieldInfo . addAll ( fieldInfoList ) ; } }
|
Add field info .
| 109
| 4
|
156,414
|
void addMethodInfo ( final MethodInfoList methodInfoList , final Map < String , ClassInfo > classNameToClassInfo ) { for ( final MethodInfo mi : methodInfoList ) { // Index method annotations addFieldOrMethodAnnotationInfo ( mi . annotationInfo , /* isField = */ false , classNameToClassInfo ) ; // Index method parameter annotations if ( mi . parameterAnnotationInfo != null ) { for ( int i = 0 ; i < mi . parameterAnnotationInfo . length ; i ++ ) { final AnnotationInfo [ ] paramAnnotationInfoArr = mi . parameterAnnotationInfo [ i ] ; if ( paramAnnotationInfoArr != null ) { for ( int j = 0 ; j < paramAnnotationInfoArr . length ; j ++ ) { final AnnotationInfo methodParamAnnotationInfo = paramAnnotationInfoArr [ j ] ; final ClassInfo annotationClassInfo = getOrCreateClassInfo ( methodParamAnnotationInfo . getName ( ) , ANNOTATION_CLASS_MODIFIER , classNameToClassInfo ) ; annotationClassInfo . addRelatedClass ( RelType . CLASSES_WITH_METHOD_PARAMETER_ANNOTATION , this ) ; this . addRelatedClass ( RelType . METHOD_PARAMETER_ANNOTATIONS , annotationClassInfo ) ; } } } } } if ( this . methodInfo == null ) { this . methodInfo = methodInfoList ; } else { this . methodInfo . addAll ( methodInfoList ) ; } }
|
Add method info .
| 327
| 4
|
156,415
|
private static Set < ClassInfo > filterClassInfo ( final Collection < ClassInfo > classes , final ScanSpec scanSpec , final boolean strictWhitelist , final ClassType ... classTypes ) { if ( classes == null ) { return Collections . < ClassInfo > emptySet ( ) ; } boolean includeAllTypes = classTypes . length == 0 ; boolean includeStandardClasses = false ; boolean includeImplementedInterfaces = false ; boolean includeAnnotations = false ; for ( final ClassType classType : classTypes ) { switch ( classType ) { case ALL : includeAllTypes = true ; break ; case STANDARD_CLASS : includeStandardClasses = true ; break ; case IMPLEMENTED_INTERFACE : includeImplementedInterfaces = true ; break ; case ANNOTATION : includeAnnotations = true ; break ; case INTERFACE_OR_ANNOTATION : includeImplementedInterfaces = includeAnnotations = true ; break ; default : throw new IllegalArgumentException ( "Unknown ClassType: " + classType ) ; } } if ( includeStandardClasses && includeImplementedInterfaces && includeAnnotations ) { includeAllTypes = true ; } final Set < ClassInfo > classInfoSetFiltered = new LinkedHashSet <> ( classes . size ( ) ) ; for ( final ClassInfo classInfo : classes ) { // Check class type against requested type(s) if ( ( includeAllTypes // || includeStandardClasses && classInfo . isStandardClass ( ) || includeImplementedInterfaces && classInfo . isImplementedInterface ( ) || includeAnnotations && classInfo . isAnnotation ( ) ) // // Always check blacklist && ! scanSpec . classOrPackageIsBlacklisted ( classInfo . name ) // // Always return whitelisted classes, or external classes if enableExternalClasses is true && ( ! classInfo . isExternalClass || scanSpec . enableExternalClasses // Return external (non-whitelisted) classes if viewing class hierarchy "upwards" || ! strictWhitelist ) ) { // Class passed strict whitelist criteria classInfoSetFiltered . add ( classInfo ) ; } } return classInfoSetFiltered ; }
|
Filter classes according to scan spec and class type .
| 462
| 10
|
156,416
|
static ClassInfoList getAllClasses ( final Collection < ClassInfo > classes , final ScanSpec scanSpec ) { return new ClassInfoList ( ClassInfo . filterClassInfo ( classes , scanSpec , /* strictWhitelist = */ true , ClassType . ALL ) , /* sortByName = */ true ) ; }
|
Get all classes found during the scan .
| 66
| 8
|
156,417
|
static ClassInfoList getAllStandardClasses ( final Collection < ClassInfo > classes , final ScanSpec scanSpec ) { return new ClassInfoList ( ClassInfo . filterClassInfo ( classes , scanSpec , /* strictWhitelist = */ true , ClassType . STANDARD_CLASS ) , /* sortByName = */ true ) ; }
|
Get all standard classes found during the scan .
| 70
| 9
|
156,418
|
public String getModifiersStr ( ) { final StringBuilder buf = new StringBuilder ( ) ; TypeUtils . modifiersToString ( modifiers , ModifierType . CLASS , /* ignored */ false , buf ) ; return buf . toString ( ) ; }
|
Get the class modifiers as a String .
| 53
| 8
|
156,419
|
public boolean hasField ( final String fieldName ) { for ( final ClassInfo ci : getOverrideOrder ( ) ) { if ( ci . hasDeclaredField ( fieldName ) ) { return true ; } } return false ; }
|
Checks whether this class or one of its superclasses has the named field .
| 50
| 16
|
156,420
|
public boolean hasDeclaredFieldAnnotation ( final String fieldAnnotationName ) { for ( final FieldInfo fi : getDeclaredFieldInfo ( ) ) { if ( fi . hasAnnotation ( fieldAnnotationName ) ) { return true ; } } return false ; }
|
Checks whether this class declares a field with the named annotation .
| 57
| 13
|
156,421
|
public boolean hasFieldAnnotation ( final String fieldAnnotationName ) { for ( final ClassInfo ci : getOverrideOrder ( ) ) { if ( ci . hasDeclaredFieldAnnotation ( fieldAnnotationName ) ) { return true ; } } return false ; }
|
Checks whether this class or one of its superclasses declares a field with the named annotation .
| 58
| 19
|
156,422
|
public boolean hasMethod ( final String methodName ) { for ( final ClassInfo ci : getOverrideOrder ( ) ) { if ( ci . hasDeclaredMethod ( methodName ) ) { return true ; } } return false ; }
|
Checks whether this class or one of its superclasses or interfaces declares a method of the given name .
| 50
| 21
|
156,423
|
public boolean hasMethodAnnotation ( final String methodAnnotationName ) { for ( final ClassInfo ci : getOverrideOrder ( ) ) { if ( ci . hasDeclaredMethodAnnotation ( methodAnnotationName ) ) { return true ; } } return false ; }
|
Checks whether this class or one of its superclasses or interfaces declares a method with the named annotation .
| 58
| 21
|
156,424
|
public boolean hasMethodParameterAnnotation ( final String methodParameterAnnotationName ) { for ( final ClassInfo ci : getOverrideOrder ( ) ) { if ( ci . hasDeclaredMethodParameterAnnotation ( methodParameterAnnotationName ) ) { return true ; } } return false ; }
|
Checks whether this class or one of its superclasses or interfaces has a method with the named annotation .
| 62
| 21
|
156,425
|
private List < ClassInfo > getOverrideOrder ( final Set < ClassInfo > visited , final List < ClassInfo > overrideOrderOut ) { if ( visited . add ( this ) ) { overrideOrderOut . add ( this ) ; for ( final ClassInfo iface : getInterfaces ( ) ) { iface . getOverrideOrder ( visited , overrideOrderOut ) ; } final ClassInfo superclass = getSuperclass ( ) ; if ( superclass != null ) { superclass . getOverrideOrder ( visited , overrideOrderOut ) ; } } return overrideOrderOut ; }
|
Recurse to interfaces and superclasses to get the order that fields and methods are overridden in .
| 120
| 20
|
156,426
|
public ClassInfoList getInterfaces ( ) { // Classes also implement the interfaces of their superclasses final ReachableAndDirectlyRelatedClasses implementedInterfaces = this . filterClassInfo ( RelType . IMPLEMENTED_INTERFACES , /* strictWhitelist = */ false ) ; final Set < ClassInfo > allInterfaces = new LinkedHashSet <> ( implementedInterfaces . reachableClasses ) ; for ( final ClassInfo superclass : this . filterClassInfo ( RelType . SUPERCLASSES , /* strictWhitelist = */ false ) . reachableClasses ) { final Set < ClassInfo > superclassImplementedInterfaces = superclass . filterClassInfo ( RelType . IMPLEMENTED_INTERFACES , /* strictWhitelist = */ false ) . reachableClasses ; allInterfaces . addAll ( superclassImplementedInterfaces ) ; } return new ClassInfoList ( allInterfaces , implementedInterfaces . directlyRelatedClasses , /* sortByName = */ true ) ; }
|
Get the interfaces implemented by this class or by one of its superclasses if this is a standard class or the superinterfaces extended by this interface if this is an interface .
| 219
| 35
|
156,427
|
private ClassInfoList getClassesWithFieldOrMethodAnnotation ( final RelType relType ) { final boolean isField = relType == RelType . CLASSES_WITH_FIELD_ANNOTATION ; if ( ! ( isField ? scanResult . scanSpec . enableFieldInfo : scanResult . scanSpec . enableMethodInfo ) || ! scanResult . scanSpec . enableAnnotationInfo ) { throw new IllegalArgumentException ( "Please call ClassGraph#enable" + ( isField ? "Field" : "Method" ) + "Info() and " + "#enableAnnotationInfo() before #scan()" ) ; } final ReachableAndDirectlyRelatedClasses classesWithDirectlyAnnotatedFieldsOrMethods = this . filterClassInfo ( relType , /* strictWhitelist = */ ! isExternalClass ) ; final ReachableAndDirectlyRelatedClasses annotationsWithThisMetaAnnotation = this . filterClassInfo ( RelType . CLASSES_WITH_ANNOTATION , /* strictWhitelist = */ ! isExternalClass , ClassType . ANNOTATION ) ; if ( annotationsWithThisMetaAnnotation . reachableClasses . isEmpty ( ) ) { // This annotation does not meta-annotate another annotation that annotates a method return new ClassInfoList ( classesWithDirectlyAnnotatedFieldsOrMethods , /* sortByName = */ true ) ; } else { // Take the union of all classes with fields or methods directly annotated by this annotation, // and classes with fields or methods meta-annotated by this annotation final Set < ClassInfo > allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods = new LinkedHashSet <> ( classesWithDirectlyAnnotatedFieldsOrMethods . reachableClasses ) ; for ( final ClassInfo metaAnnotatedAnnotation : annotationsWithThisMetaAnnotation . reachableClasses ) { allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods . addAll ( metaAnnotatedAnnotation . filterClassInfo ( relType , /* strictWhitelist = */ ! metaAnnotatedAnnotation . isExternalClass ) . reachableClasses ) ; } return new ClassInfoList ( allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods , classesWithDirectlyAnnotatedFieldsOrMethods . directlyRelatedClasses , /* sortByName = */ true ) ; } }
|
Get the classes that have this class as a field method or method parameter annotation .
| 513
| 16
|
156,428
|
public AnnotationParameterValueList getAnnotationDefaultParameterValues ( ) { if ( ! scanResult . scanSpec . enableAnnotationInfo ) { throw new IllegalArgumentException ( "Please call ClassGraph#enableAnnotationInfo() before #scan()" ) ; } if ( ! isAnnotation ) { throw new IllegalArgumentException ( "Class is not an annotation: " + getName ( ) ) ; } if ( annotationDefaultParamValues == null ) { return AnnotationParameterValueList . EMPTY_LIST ; } if ( ! annotationDefaultParamValuesHasBeenConvertedToPrimitive ) { annotationDefaultParamValues . convertWrapperArraysToPrimitiveArrays ( this ) ; annotationDefaultParamValuesHasBeenConvertedToPrimitive = true ; } return annotationDefaultParamValues ; }
|
Get the default parameter values for this annotation if this is an annotation class .
| 169
| 15
|
156,429
|
public ClassInfoList getClassesWithAnnotation ( ) { if ( ! scanResult . scanSpec . enableAnnotationInfo ) { throw new IllegalArgumentException ( "Please call ClassGraph#enableAnnotationInfo() before #scan()" ) ; } if ( ! isAnnotation ) { throw new IllegalArgumentException ( "Class is not an annotation: " + getName ( ) ) ; } // Get classes that have this annotation final ReachableAndDirectlyRelatedClasses classesWithAnnotation = this . filterClassInfo ( RelType . CLASSES_WITH_ANNOTATION , /* strictWhitelist = */ ! isExternalClass ) ; if ( isInherited ) { // If this is an inherited annotation, add into the result all subclasses of the annotated classes. final Set < ClassInfo > classesWithAnnotationAndTheirSubclasses = new LinkedHashSet <> ( classesWithAnnotation . reachableClasses ) ; for ( final ClassInfo classWithAnnotation : classesWithAnnotation . reachableClasses ) { classesWithAnnotationAndTheirSubclasses . addAll ( classWithAnnotation . getSubclasses ( ) ) ; } return new ClassInfoList ( classesWithAnnotationAndTheirSubclasses , classesWithAnnotation . directlyRelatedClasses , /* sortByName = */ true ) ; } else { // If not inherited, only return the annotated classes return new ClassInfoList ( classesWithAnnotation , /* sortByName = */ true ) ; } }
|
Get the classes that have this class as an annotation .
| 316
| 11
|
156,430
|
public ClassTypeSignature getTypeSignature ( ) { if ( typeSignatureStr == null ) { return null ; } if ( typeSignature == null ) { try { typeSignature = ClassTypeSignature . parse ( typeSignatureStr , this ) ; typeSignature . setScanResult ( scanResult ) ; } catch ( final ParseException e ) { throw new IllegalArgumentException ( e ) ; } } return typeSignature ; }
|
Get the type signature of the class .
| 96
| 8
|
156,431
|
void addReferencedClassNames ( final Set < String > refdClassNames ) { if ( this . referencedClassNames == null ) { this . referencedClassNames = refdClassNames ; } else { this . referencedClassNames . addAll ( refdClassNames ) ; } }
|
Add names of classes referenced by this class .
| 61
| 9
|
156,432
|
@ Override protected void findReferencedClassNames ( final Set < String > referencedClassNames ) { if ( this . referencedClassNames != null ) { referencedClassNames . addAll ( this . referencedClassNames ) ; } getMethodInfo ( ) . findReferencedClassNames ( referencedClassNames ) ; getFieldInfo ( ) . findReferencedClassNames ( referencedClassNames ) ; getAnnotationInfo ( ) . findReferencedClassNames ( referencedClassNames ) ; if ( annotationDefaultParamValues != null ) { annotationDefaultParamValues . findReferencedClassNames ( referencedClassNames ) ; } final ClassTypeSignature classSig = getTypeSignature ( ) ; if ( classSig != null ) { classSig . findReferencedClassNames ( referencedClassNames ) ; } // Remove any self-references referencedClassNames . remove ( name ) ; }
|
Get the names of any classes referenced in this class type descriptor or the type descriptors of fields methods or annotations .
| 190
| 23
|
156,433
|
public ClassInfoList getClassDependencies ( ) { if ( ! scanResult . scanSpec . enableInterClassDependencies ) { throw new IllegalArgumentException ( "Please call ClassGraph#enableInterClassDependencies() before #scan()" ) ; } return referencedClasses == null ? ClassInfoList . EMPTY_LIST : referencedClasses ; }
|
Get the class dependencies .
| 78
| 5
|
156,434
|
private static void translateSeparator ( final String path , final int startIdx , final int endIdx , final boolean stripFinalSeparator , final StringBuilder buf ) { for ( int i = startIdx ; i < endIdx ; i ++ ) { final char c = path . charAt ( i ) ; if ( c == ' ' || c == ' ' ) { // Strip trailing separator, if necessary if ( i < endIdx - 1 || ! stripFinalSeparator ) { // Remove duplicate separators final char prevChar = buf . length ( ) == 0 ? ' ' : buf . charAt ( buf . length ( ) - 1 ) ; if ( prevChar != ' ' ) { buf . append ( ' ' ) ; } } } else { buf . append ( c ) ; } } }
|
Translate backslashes to forward slashes optionally removing trailing separator .
| 175
| 15
|
156,435
|
private TypeSignature getTypeSignature ( ) { if ( typeSignature == null ) { try { // There can't be any type variables to resolve in either ClassRefTypeSignature or // BaseTypeSignature, so just set definingClassName to null typeSignature = TypeSignature . parse ( typeDescriptorStr , /* definingClassName = */ null ) ; typeSignature . setScanResult ( scanResult ) ; } catch ( final ParseException e ) { throw new IllegalArgumentException ( e ) ; } } return typeSignature ; }
|
Get the type signature .
| 118
| 5
|
156,436
|
private String sanitizeFilename ( final String filename ) { return filename . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) ; }
|
Sanitize filename .
| 79
| 5
|
156,437
|
private File makeTempFile ( final String filePath , final boolean onlyUseLeafname ) throws IOException { final File tempFile = File . createTempFile ( "ClassGraph--" , TEMP_FILENAME_LEAF_SEPARATOR + sanitizeFilename ( onlyUseLeafname ? leafname ( filePath ) : filePath ) ) ; tempFile . deleteOnExit ( ) ; tempFiles . add ( tempFile ) ; return tempFile ; }
|
Create a temporary file and mark it for deletion on exit .
| 100
| 12
|
156,438
|
private File downloadTempFile ( final String jarURL , final LogNode log ) { final LogNode subLog = log == null ? null : log . log ( jarURL , "Downloading URL " + jarURL ) ; File tempFile ; try { tempFile = makeTempFile ( jarURL , /* onlyUseLeafname = */ true ) ; final URL url = new URL ( jarURL ) ; try ( InputStream inputStream = url . openStream ( ) ) { Files . copy ( inputStream , tempFile . toPath ( ) , StandardCopyOption . REPLACE_EXISTING ) ; } if ( subLog != null ) { subLog . addElapsedTime ( ) ; } } catch ( final IOException | SecurityException e ) { if ( subLog != null ) { subLog . log ( "Could not download " + jarURL , e ) ; } return null ; } if ( subLog != null ) { subLog . log ( "Downloaded to temporary file " + tempFile ) ; subLog . log ( "***** Note that it is time-consuming to scan jars at http(s) addresses, " + "they must be downloaded for every scan, and the same jars must also be " + "separately downloaded by the ClassLoader *****" ) ; } return tempFile ; }
|
Download a jar from a URL to a temporary file .
| 276
| 11
|
156,439
|
public String generateGraphVizDotFile ( final float sizeX , final float sizeY ) { return generateGraphVizDotFile ( sizeX , sizeY , /* showFields = */ true , /* showFieldTypeDependencyEdges = */ true , /* showMethods = */ true , /* showMethodTypeDependencyEdges = */ true , /* showAnnotations = */ true ) ; }
|
Generate a . dot file which can be fed into GraphViz for layout and visualization of the class graph .
| 87
| 23
|
156,440
|
public void generateGraphVizDotFile ( final File file ) throws IOException { try ( PrintWriter writer = new PrintWriter ( file ) ) { writer . print ( generateGraphVizDotFile ( ) ) ; } }
|
Generate a and save a . dot file which can be fed into GraphViz for layout and visualization of the class graph .
| 49
| 26
|
156,441
|
public boolean containsName ( final String name ) { for ( final T i : this ) { if ( i . getName ( ) . equals ( name ) ) { return true ; } } return false ; }
|
Check if this list contains an item with the given name .
| 43
| 12
|
156,442
|
public T get ( final String name ) { for ( final T i : this ) { if ( i . getName ( ) . equals ( name ) ) { return i ; } } return null ; }
|
Get the list item with the given name or null if not found .
| 42
| 14
|
156,443
|
public static < U > void runWorkQueue ( final Collection < U > elements , final ExecutorService executorService , final InterruptionChecker interruptionChecker , final int numParallelTasks , final LogNode log , final WorkUnitProcessor < U > workUnitProcessor ) throws InterruptedException , ExecutionException { if ( elements . isEmpty ( ) ) { // Nothing to do return ; } // WorkQueue#close() is called when this try-with-resources block terminates, initiating a barrier wait // while all worker threads complete. try ( WorkQueue < U > workQueue = new WorkQueue <> ( elements , workUnitProcessor , numParallelTasks , interruptionChecker , log ) ) { // Start (numParallelTasks - 1) worker threads (may start zero threads if numParallelTasks == 1) workQueue . startWorkers ( executorService , numParallelTasks - 1 ) ; // Use the current thread to do work too, in case there is only one thread available in the // ExecutorService, or in case numParallelTasks is greater than the number of available threads in the // ExecutorService. workQueue . runWorkLoop ( ) ; } }
|
Start a work queue on the elements in the provided collection blocking until all work units have been completed .
| 258
| 20
|
156,444
|
private void startWorkers ( final ExecutorService executorService , final int numTasks ) { for ( int i = 0 ; i < numTasks ; i ++ ) { workerFutures . add ( executorService . submit ( new Callable < Void > ( ) { @ Override public Void call ( ) throws Exception { runWorkLoop ( ) ; return null ; } } ) ) ; } }
|
Start worker threads with a shared log .
| 87
| 8
|
156,445
|
private void sendPoisonPills ( ) { for ( int i = 0 ; i < numWorkers ; i ++ ) { workUnits . add ( new WorkUnitWrapper < T > ( null ) ) ; } }
|
Send poison pills to workers .
| 48
| 6
|
156,446
|
public void addWorkUnit ( final T workUnit ) { if ( workUnit == null ) { throw new NullPointerException ( "workUnit cannot be null" ) ; } numIncompleteWorkUnits . incrementAndGet ( ) ; workUnits . add ( new WorkUnitWrapper <> ( workUnit ) ) ; }
|
Add a unit of work . May be called by workers to add more work units to the tail of the queue .
| 70
| 23
|
156,447
|
ClassFields get ( final Class < ? > cls ) { ClassFields classFields = classToClassFields . get ( cls ) ; if ( classFields == null ) { classToClassFields . put ( cls , classFields = new ClassFields ( cls , resolveTypes , onlySerializePublicFields , this ) ) ; } return classFields ; }
|
For a given resolved type find the visible and accessible fields resolve the types of any generically typed fields and return the resolved fields .
| 86
| 26
|
156,448
|
private static Class < ? > getConcreteType ( final Class < ? > rawType , final boolean returnNullIfNotMapOrCollection ) { // This list is not complete (e.g. EnumMap cannot be instantiated directly, you need to pass the // enum key type into a factory method), but this should cover a lot of the common types if ( rawType == Map . class || rawType == AbstractMap . class || rawType == HashMap . class ) { return HashMap . class ; } else if ( rawType == ConcurrentMap . class || rawType == ConcurrentHashMap . class ) { return ConcurrentHashMap . class ; } else if ( rawType == SortedMap . class || rawType == NavigableMap . class || rawType == TreeMap . class ) { return TreeMap . class ; } else if ( rawType == ConcurrentNavigableMap . class || rawType == ConcurrentSkipListMap . class ) { return ConcurrentSkipListMap . class ; } else if ( rawType == List . class || rawType == AbstractList . class || rawType == ArrayList . class || rawType == Collection . class ) { return ArrayList . class ; } else if ( rawType == AbstractSequentialList . class || rawType == LinkedList . class ) { return LinkedList . class ; } else if ( rawType == Set . class || rawType == AbstractSet . class || rawType == HashSet . class ) { return HashSet . class ; } else if ( rawType == SortedSet . class || rawType == TreeSet . class ) { return TreeSet . class ; } else if ( rawType == Queue . class || rawType == AbstractQueue . class || rawType == Deque . class || rawType == ArrayDeque . class ) { return ArrayDeque . class ; } else if ( rawType == BlockingQueue . class || rawType == LinkedBlockingQueue . class ) { return LinkedBlockingQueue . class ; } else if ( rawType == BlockingDeque . class || rawType == LinkedBlockingDeque . class ) { return LinkedBlockingDeque . class ; } else if ( rawType == TransferQueue . class || rawType == LinkedTransferQueue . class ) { return LinkedTransferQueue . class ; } else { return returnNullIfNotMapOrCollection ? null : rawType ; } }
|
Get the concrete type for a map or collection whose raw type is an interface or abstract class .
| 513
| 19
|
156,449
|
Constructor < ? > getDefaultConstructorForConcreteTypeOf ( final Class < ? > cls ) { if ( cls == null ) { throw new IllegalArgumentException ( "Class reference cannot be null" ) ; } // Check cache final Constructor < ? > constructor = defaultConstructorForConcreteType . get ( cls ) ; if ( constructor != null ) { return constructor ; } final Class < ? > concreteType = getConcreteType ( cls , /* returnNullIfNotMapOrCollection = */ false ) ; for ( Class < ? > c = concreteType ; c != null && ( c != Object . class || cls == Object . class ) ; c = c . getSuperclass ( ) ) { try { final Constructor < ? > defaultConstructor = c . getDeclaredConstructor ( ) ; JSONUtils . isAccessibleOrMakeAccessible ( defaultConstructor ) ; // Store found constructor in cache defaultConstructorForConcreteType . put ( cls , defaultConstructor ) ; return defaultConstructor ; } catch ( final ReflectiveOperationException | SecurityException e ) { // Ignore } } throw new IllegalArgumentException ( "Class " + cls . getName ( ) // + " does not have an accessible default (no-arg) constructor" ) ; }
|
Get the concrete type of the given class then return the default constructor for that type .
| 278
| 17
|
156,450
|
static Object getFieldValue ( final Object containingObj , final Field field ) throws IllegalArgumentException , IllegalAccessException { final Class < ? > fieldType = field . getType ( ) ; if ( fieldType == Integer . TYPE ) { return field . getInt ( containingObj ) ; } else if ( fieldType == Long . TYPE ) { return field . getLong ( containingObj ) ; } else if ( fieldType == Short . TYPE ) { return field . getShort ( containingObj ) ; } else if ( fieldType == Double . TYPE ) { return field . getDouble ( containingObj ) ; } else if ( fieldType == Float . TYPE ) { return field . getFloat ( containingObj ) ; } else if ( fieldType == Boolean . TYPE ) { return field . getBoolean ( containingObj ) ; } else if ( fieldType == Byte . TYPE ) { return field . getByte ( containingObj ) ; } else if ( fieldType == Character . TYPE ) { return field . getChar ( containingObj ) ; } else { return field . get ( containingObj ) ; } }
|
Get a field value appropriately handling primitive - typed fields .
| 229
| 11
|
156,451
|
static boolean isBasicValueType ( final Type type ) { if ( type instanceof Class < ? > ) { return isBasicValueType ( ( Class < ? > ) type ) ; } else if ( type instanceof ParameterizedType ) { return isBasicValueType ( ( ( ParameterizedType ) type ) . getRawType ( ) ) ; } else { return false ; } }
|
Return true for types that can be converted directly to and from string representation .
| 82
| 15
|
156,452
|
static boolean isBasicValueType ( final Object obj ) { return obj == null || obj instanceof String || obj instanceof Integer || obj instanceof Boolean || obj instanceof Long || obj instanceof Float || obj instanceof Double || obj instanceof Short || obj instanceof Byte || obj instanceof Character || obj . getClass ( ) . isEnum ( ) ; }
|
Return true for objects that can be converted directly to and from string representation .
| 76
| 15
|
156,453
|
static boolean fieldIsSerializable ( final Field field , final boolean onlySerializePublicFields ) { final int modifiers = field . getModifiers ( ) ; if ( ( ! onlySerializePublicFields || Modifier . isPublic ( modifiers ) ) && ! Modifier . isTransient ( modifiers ) && ! Modifier . isFinal ( modifiers ) && ( ( modifiers & 0x1000 /* synthetic */ ) == 0 ) ) { return JSONUtils . isAccessibleOrMakeAccessible ( field ) ; } return false ; }
|
Check if a field is serializable . Don t serialize transient final synthetic or inaccessible fields .
| 112
| 19
|
156,454
|
public AnnotationParameterValueList getParameterValues ( ) { if ( annotationParamValuesWithDefaults == null ) { final ClassInfo classInfo = getClassInfo ( ) ; if ( classInfo == null ) { // ClassInfo has not yet been set, just return values without defaults // (happens when trying to log AnnotationInfo during scanning, before ScanResult is available) return annotationParamValues == null ? AnnotationParameterValueList . EMPTY_LIST : annotationParamValues ; } // Lazily convert any Object[] arrays of boxed types to primitive arrays if ( annotationParamValues != null && ! annotationParamValuesHasBeenConvertedToPrimitive ) { annotationParamValues . convertWrapperArraysToPrimitiveArrays ( classInfo ) ; annotationParamValuesHasBeenConvertedToPrimitive = true ; } if ( classInfo . annotationDefaultParamValues != null && ! classInfo . annotationDefaultParamValuesHasBeenConvertedToPrimitive ) { classInfo . annotationDefaultParamValues . convertWrapperArraysToPrimitiveArrays ( classInfo ) ; classInfo . annotationDefaultParamValuesHasBeenConvertedToPrimitive = true ; } // Check if one or both of the defaults and the values in this annotation instance are null (empty) final AnnotationParameterValueList defaultParamValues = classInfo . annotationDefaultParamValues ; if ( defaultParamValues == null && annotationParamValues == null ) { return AnnotationParameterValueList . EMPTY_LIST ; } else if ( defaultParamValues == null ) { return annotationParamValues ; } else if ( annotationParamValues == null ) { return defaultParamValues ; } // Overwrite defaults with non-defaults final Map < String , Object > allParamValues = new HashMap <> ( ) ; for ( final AnnotationParameterValue defaultParamValue : defaultParamValues ) { allParamValues . put ( defaultParamValue . getName ( ) , defaultParamValue . getValue ( ) ) ; } for ( final AnnotationParameterValue annotationParamValue : this . annotationParamValues ) { allParamValues . put ( annotationParamValue . getName ( ) , annotationParamValue . getValue ( ) ) ; } // Put annotation values in the same order as the annotation methods (there is one method for each // annotation constant) if ( classInfo . methodInfo == null ) { // Should not happen (when classfile is read, methods are always read, whether or not // scanSpec.enableMethodInfo is true) throw new IllegalArgumentException ( "Could not find methods for annotation " + classInfo . getName ( ) ) ; } annotationParamValuesWithDefaults = new AnnotationParameterValueList ( ) ; for ( final MethodInfo mi : classInfo . methodInfo ) { final String paramName = mi . getName ( ) ; switch ( paramName ) { // None of these method names should be present in the @interface class itself, it should only // contain methods for the annotation constants (but skip them anyway to be safe). These methods // should only exist in concrete instances of the annotation. case "<init>" : case "<clinit>" : case "hashCode" : case "equals" : case "toString" : case "annotationType" : // Skip break ; default : // Annotation constant final Object paramValue = allParamValues . get ( paramName ) ; // Annotation values cannot be null (or absent, from either defaults or annotation instance) if ( paramValue != null ) { annotationParamValuesWithDefaults . add ( new AnnotationParameterValue ( paramName , paramValue ) ) ; } break ; } } } return annotationParamValuesWithDefaults ; }
|
Get the parameter values .
| 767
| 5
|
156,455
|
public AnnotationInfoList getAnnotationInfo ( ) { if ( ! scanResult . scanSpec . enableAnnotationInfo ) { throw new IllegalArgumentException ( "Please call ClassGraph#enableAnnotationInfo() before #scan()" ) ; } return annotationInfo == null ? AnnotationInfoList . EMPTY_LIST : AnnotationInfoList . getIndirectAnnotations ( annotationInfo , /* annotatedClass = */ null ) ; }
|
Get a list of annotations on this method along with any annotation parameter values .
| 93
| 15
|
156,456
|
public boolean hasParameterAnnotation ( final String annotationName ) { for ( final MethodParameterInfo methodParameterInfo : getParameterInfo ( ) ) { if ( methodParameterInfo . hasAnnotation ( annotationName ) ) { return true ; } } return false ; }
|
Check if this method has a parameter with the named annotation .
| 54
| 12
|
156,457
|
@ Override public int compareTo ( final MethodInfo other ) { final int diff0 = declaringClassName . compareTo ( other . declaringClassName ) ; if ( diff0 != 0 ) { return diff0 ; } final int diff1 = name . compareTo ( other . name ) ; if ( diff1 != 0 ) { return diff1 ; } return typeDescriptorStr . compareTo ( other . typeDescriptorStr ) ; }
|
Sort in order of class name method name then type descriptor .
| 94
| 12
|
156,458
|
public static synchronized String getVersion ( ) { // Try to get version number from pom.xml (available when running in Eclipse) final Class < ? > cls = ClassGraph . class ; try { final String className = cls . getName ( ) ; final URL classpathResource = cls . getResource ( "/" + JarUtils . classNameToClassfilePath ( className ) ) ; if ( classpathResource != null ) { final Path absolutePackagePath = Paths . get ( classpathResource . toURI ( ) ) . getParent ( ) ; final int packagePathSegments = className . length ( ) - className . replace ( "." , "" ) . length ( ) ; // Remove package segments from path Path path = absolutePackagePath ; for ( int i = 0 ; i < packagePathSegments && path != null ; i ++ ) { path = path . getParent ( ) ; } // Remove up to two more levels for "bin" or "target/classes" for ( int i = 0 ; i < 3 && path != null ; i ++ , path = path . getParent ( ) ) { final Path pom = path . resolve ( "pom.xml" ) ; try ( InputStream is = Files . newInputStream ( pom ) ) { final Document doc = DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) . parse ( is ) ; doc . getDocumentElement ( ) . normalize ( ) ; String version = ( String ) XPathFactory . newInstance ( ) . newXPath ( ) . compile ( "/project/version" ) . evaluate ( doc , XPathConstants . STRING ) ; if ( version != null ) { version = version . trim ( ) ; if ( ! version . isEmpty ( ) ) { return version ; } } } catch ( final IOException e ) { // Not found } } } } catch ( final Exception e ) { // Ignore } // Try to get version number from maven properties in jar's META-INF directory try ( InputStream is = cls . getResourceAsStream ( "/META-INF/maven/" + MAVEN_PACKAGE + "/" + MAVEN_ARTIFACT + "/pom.properties" ) ) { if ( is != null ) { final Properties p = new Properties ( ) ; p . load ( is ) ; final String version = p . getProperty ( "version" , "" ) . trim ( ) ; if ( ! version . isEmpty ( ) ) { return version ; } } } catch ( final IOException e ) { // Ignore } // Fallback to using Java API (version number is obtained from MANIFEST.MF) final Package pkg = cls . getPackage ( ) ; if ( pkg != null ) { String version = pkg . getImplementationVersion ( ) ; if ( version == null ) { version = "" ; } version = version . trim ( ) ; if ( version . isEmpty ( ) ) { version = pkg . getSpecificationVersion ( ) ; if ( version == null ) { version = "" ; } version = version . trim ( ) ; } if ( ! version . isEmpty ( ) ) { return version ; } } return "unknown" ; }
|
Get the version number of ClassGraph .
| 690
| 8
|
156,459
|
private ByteBuffer getChunk ( final int chunkIdx ) throws IOException , InterruptedException { ByteBuffer chunk = chunkCache [ chunkIdx ] ; if ( chunk == null ) { final ByteBuffer byteBufferDup = zipFileSlice . physicalZipFile . getByteBuffer ( chunkIdx ) . duplicate ( ) ; chunk = chunkCache [ chunkIdx ] = byteBufferDup ; } return chunk ; }
|
Get the 2GB chunk of the zipfile with the given chunk index .
| 90
| 15
|
156,460
|
static int getShort ( final byte [ ] arr , final long off ) throws IndexOutOfBoundsException { final int ioff = ( int ) off ; if ( ioff < 0 || ioff > arr . length - 2 ) { throw new IndexOutOfBoundsException ( ) ; } return ( ( arr [ ioff + 1 ] & 0xff ) << 8 ) | ( arr [ ioff ] & 0xff ) ; }
|
Get a short from a byte array .
| 92
| 8
|
156,461
|
int getShort ( final long off ) throws IOException , InterruptedException { if ( off < 0 || off > zipFileSlice . len - 2 ) { throw new IndexOutOfBoundsException ( ) ; } if ( read ( off , scratch , 0 , 2 ) < 2 ) { throw new EOFException ( "Unexpected EOF" ) ; } return ( ( scratch [ 1 ] & 0xff ) << 8 ) | ( scratch [ 0 ] & 0xff ) ; }
|
Get a short from the zipfile slice .
| 103
| 9
|
156,462
|
static int getInt ( final byte [ ] arr , final long off ) throws IOException { final int ioff = ( int ) off ; if ( ioff < 0 || ioff > arr . length - 4 ) { throw new IndexOutOfBoundsException ( ) ; } return ( ( arr [ ioff + 3 ] & 0xff ) << 24 ) // | ( ( arr [ ioff + 2 ] & 0xff ) << 16 ) // | ( ( arr [ ioff + 1 ] & 0xff ) << 8 ) // | ( arr [ ioff ] & 0xff ) ; }
|
Get an int from a byte array .
| 125
| 8
|
156,463
|
static long getLong ( final byte [ ] arr , final long off ) throws IOException { final int ioff = ( int ) off ; if ( ioff < 0 || ioff > arr . length - 8 ) { throw new IndexOutOfBoundsException ( ) ; } return ( ( arr [ ioff + 7 ] & 0xff L ) << 56 ) // | ( ( arr [ ioff + 6 ] & 0xff L ) << 48 ) // | ( ( arr [ ioff + 5 ] & 0xff L ) << 40 ) // | ( ( arr [ ioff + 4 ] & 0xff L ) << 32 ) // | ( ( arr [ ioff + 3 ] & 0xff L ) << 24 ) // | ( ( arr [ ioff + 2 ] & 0xff L ) << 16 ) // | ( ( arr [ ioff + 1 ] & 0xff L ) << 8 ) // | ( arr [ ioff ] & 0xff L ) ; }
|
Get a long from a byte array .
| 205
| 8
|
156,464
|
long getLong ( final long off ) throws IOException , InterruptedException { if ( off < 0 || off > zipFileSlice . len - 8 ) { throw new IndexOutOfBoundsException ( ) ; } if ( read ( off , scratch , 0 , 8 ) < 8 ) { throw new EOFException ( "Unexpected EOF" ) ; } return ( ( scratch [ 7 ] & 0xff L ) << 56 ) // | ( ( scratch [ 6 ] & 0xff L ) << 48 ) // | ( ( scratch [ 5 ] & 0xff L ) << 40 ) // | ( ( scratch [ 4 ] & 0xff L ) << 32 ) // | ( ( scratch [ 3 ] & 0xff L ) << 24 ) // | ( ( scratch [ 2 ] & 0xff L ) << 16 ) // | ( ( scratch [ 1 ] & 0xff L ) << 8 ) // | ( scratch [ 0 ] & 0xff L ) ; }
|
Get a long from the zipfile slice .
| 202
| 9
|
156,465
|
static String getString ( final byte [ ] arr , final long off , final int lenBytes ) throws IOException { final int ioff = ( int ) off ; if ( ioff < 0 || ioff > arr . length - lenBytes ) { throw new IndexOutOfBoundsException ( ) ; } return new String ( arr , ioff , lenBytes , StandardCharsets . UTF_8 ) ; }
|
Get a string from a byte array .
| 87
| 8
|
156,466
|
String getString ( final long off , final int lenBytes ) throws IOException , InterruptedException { if ( off < 0 || off > zipFileSlice . len - lenBytes ) { throw new IndexOutOfBoundsException ( ) ; } final byte [ ] scratchToUse = lenBytes <= scratch . length ? scratch : new byte [ lenBytes ] ; if ( read ( off , scratchToUse , 0 , lenBytes ) < lenBytes ) { throw new EOFException ( "Unexpected EOF" ) ; } // Assume the entry names are encoded in UTF-8 (should be the case for all jars; the only other // valid zipfile charset is CP437, which is the same as ASCII for printable high-bit-clear chars) return new String ( scratchToUse , 0 , lenBytes , StandardCharsets . UTF_8 ) ; }
|
Get a string from the zipfile slice .
| 185
| 9
|
156,467
|
static ReferenceTypeSignature parseReferenceTypeSignature ( final Parser parser , final String definingClassName ) throws ParseException { final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature . parse ( parser , definingClassName ) ; if ( classTypeSignature != null ) { return classTypeSignature ; } final TypeVariableSignature typeVariableSignature = TypeVariableSignature . parse ( parser , definingClassName ) ; if ( typeVariableSignature != null ) { return typeVariableSignature ; } final ArrayTypeSignature arrayTypeSignature = ArrayTypeSignature . parse ( parser , definingClassName ) ; if ( arrayTypeSignature != null ) { return arrayTypeSignature ; } return null ; }
|
Parse a reference type signature .
| 156
| 7
|
156,468
|
static ReferenceTypeSignature parseClassBound ( final Parser parser , final String definingClassName ) throws ParseException { parser . expect ( ' ' ) ; // May return null if there is no signature after ':' (class bound signature may be empty) return parseReferenceTypeSignature ( parser , definingClassName ) ; }
|
Parse a class bound .
| 68
| 6
|
156,469
|
public static boolean isClassfile ( final String path ) { final int len = path . length ( ) ; return len > 6 && path . regionMatches ( true , len - 6 , ".class" , 0 , 6 ) ; }
|
Check if the path ends with a . class extension ignoring case .
| 49
| 13
|
156,470
|
public static String getParentDirPath ( final String path , final char separator ) { final int lastSlashIdx = path . lastIndexOf ( separator ) ; if ( lastSlashIdx <= 0 ) { return "" ; } return path . substring ( 0 , lastSlashIdx ) ; }
|
Get the parent dir path .
| 67
| 6
|
156,471
|
public static Object getStaticFieldVal ( final Class < ? > cls , final String fieldName , final boolean throwException ) throws IllegalArgumentException { if ( cls == null || fieldName == null ) { if ( throwException ) { throw new NullPointerException ( ) ; } else { return null ; } } return getFieldVal ( cls , null , fieldName , throwException ) ; }
|
Get the value of the named static field in the given class or any of its superclasses . If an exception is thrown while trying to read the field value and throwException is true then IllegalArgumentException is thrown wrapping the cause otherwise this will return null . If passed a null class reference returns null unless throwException is true then throws IllegalArgumentException .
| 86
| 72
|
156,472
|
private static String getContentLocation ( final Object content ) { final File file = ( File ) ReflectionUtils . invokeMethod ( content , "getFile" , false ) ; return file != null ? file . toURI ( ) . toString ( ) : null ; }
|
Get the content location .
| 57
| 5
|
156,473
|
private static void addBundle ( final Object bundleWiring , final ClassLoader classLoader , final ClasspathOrder classpathOrderOut , final Set < Object > bundles , final ScanSpec scanSpec , final LogNode log ) { // Track the bundles we've processed to prevent loops bundles . add ( bundleWiring ) ; // Get the revision for this wiring final Object revision = ReflectionUtils . invokeMethod ( bundleWiring , "getRevision" , false ) ; // Get the contents final Object content = ReflectionUtils . invokeMethod ( revision , "getContent" , false ) ; final String location = content != null ? getContentLocation ( content ) : null ; if ( location != null ) { // Add the bundle object classpathOrderOut . addClasspathEntry ( location , classLoader , scanSpec , log ) ; // And any embedded content final List < ? > embeddedContent = ( List < ? > ) ReflectionUtils . invokeMethod ( revision , "getContentPath" , false ) ; if ( embeddedContent != null ) { for ( final Object embedded : embeddedContent ) { if ( embedded != content ) { final String embeddedLocation = embedded != null ? getContentLocation ( embedded ) : null ; if ( embeddedLocation != null ) { classpathOrderOut . addClasspathEntry ( embeddedLocation , classLoader , scanSpec , log ) ; } } } } } }
|
Adds the bundle .
| 291
| 4
|
156,474
|
void toStringParamValueOnly ( final StringBuilder buf ) { if ( value == null ) { buf . append ( "null" ) ; } else { final Object paramVal = value . get ( ) ; final Class < ? > valClass = paramVal . getClass ( ) ; if ( valClass . isArray ( ) ) { buf . append ( ' ' ) ; for ( int j = 0 , n = Array . getLength ( paramVal ) ; j < n ; j ++ ) { if ( j > 0 ) { buf . append ( ", " ) ; } final Object elt = Array . get ( paramVal , j ) ; buf . append ( elt == null ? "null" : elt . toString ( ) ) ; } buf . append ( ' ' ) ; } else if ( paramVal instanceof String ) { buf . append ( ' ' ) ; buf . append ( paramVal . toString ( ) . replace ( "\"" , "\\\"" ) . replace ( "\n" , "\\n" ) . replace ( "\r" , "\\r" ) ) ; buf . append ( ' ' ) ; } else if ( paramVal instanceof Character ) { buf . append ( ' ' ) ; buf . append ( paramVal . toString ( ) . replace ( "'" , "\\'" ) . replace ( "\n" , "\\n" ) . replace ( "\r" , "\\r" ) ) ; buf . append ( ' ' ) ; } else { buf . append ( paramVal . toString ( ) ) ; } } }
|
To string param value only .
| 335
| 6
|
156,475
|
private static boolean addJREPath ( final File dir ) { if ( dir != null && ! dir . getPath ( ) . isEmpty ( ) && FileUtils . canRead ( dir ) && dir . isDirectory ( ) ) { final File [ ] dirFiles = dir . listFiles ( ) ; if ( dirFiles != null ) { for ( final File file : dirFiles ) { final String filePath = file . getPath ( ) ; if ( filePath . endsWith ( ".jar" ) ) { final String jarPathResolved = FastPathResolver . resolve ( FileUtils . CURR_DIR_PATH , filePath ) ; if ( jarPathResolved . endsWith ( "/rt.jar" ) ) { RT_JARS . add ( jarPathResolved ) ; } else { JRE_LIB_OR_EXT_JARS . add ( jarPathResolved ) ; } try { final File canonicalFile = file . getCanonicalFile ( ) ; final String canonicalFilePath = canonicalFile . getPath ( ) ; if ( ! canonicalFilePath . equals ( filePath ) ) { final String canonicalJarPathResolved = FastPathResolver . resolve ( FileUtils . CURR_DIR_PATH , filePath ) ; JRE_LIB_OR_EXT_JARS . add ( canonicalJarPathResolved ) ; } } catch ( IOException | SecurityException e ) { // Ignored } } } return true ; } } return false ; }
|
Add and search a JRE path .
| 315
| 8
|
156,476
|
private static Entry < String , Integer > getManifestValue ( final byte [ ] manifest , final int startIdx ) { // See if manifest entry is split across multiple lines int curr = startIdx ; final int len = manifest . length ; while ( curr < len && manifest [ curr ] == ( byte ) ' ' ) { // Skip initial spaces curr ++ ; } final int firstNonSpaceIdx = curr ; boolean isMultiLine = false ; for ( ; curr < len && ! isMultiLine ; curr ++ ) { final byte b = manifest [ curr ] ; if ( b == ( byte ) ' ' && curr < len - 1 && manifest [ curr + 1 ] == ( byte ) ' ' ) { if ( curr < len - 2 && manifest [ curr + 2 ] == ( byte ) ' ' ) { isMultiLine = true ; } break ; } else if ( b == ( byte ) ' ' || b == ( byte ) ' ' ) { if ( curr < len - 1 && manifest [ curr + 1 ] == ( byte ) ' ' ) { isMultiLine = true ; } break ; } } String val ; if ( ! isMultiLine ) { // Fast path for single-line value val = new String ( manifest , firstNonSpaceIdx , curr - firstNonSpaceIdx , StandardCharsets . UTF_8 ) ; } else { // Skip (newline + space) sequences in multi-line values final ByteArrayOutputStream buf = new ByteArrayOutputStream ( ) ; curr = firstNonSpaceIdx ; for ( ; curr < len ; curr ++ ) { final byte b = manifest [ curr ] ; boolean isLineEnd ; if ( b == ( byte ) ' ' && curr < len - 1 && manifest [ curr + 1 ] == ( byte ) ' ' ) { // CRLF curr += 2 ; isLineEnd = true ; } else if ( b == ' ' || b == ' ' ) { // CR or LF curr += 1 ; isLineEnd = true ; } else { buf . write ( b ) ; isLineEnd = false ; } if ( isLineEnd && curr < len && manifest [ curr ] != ( byte ) ' ' ) { // Value ends if line break is not followed by a space break ; } // If line break was followed by a space, then the curr++ in the for loop header will skip it } try { val = buf . toString ( "UTF-8" ) ; } catch ( final UnsupportedEncodingException e ) { // Should not happen throw ClassGraphException . newClassGraphException ( "UTF-8 encoding unsupported" , e ) ; } } return new SimpleEntry <> ( val . endsWith ( " " ) ? val . trim ( ) : val , curr ) ; }
|
Extract a value from the manifest and return the value as a string along with the index after the terminating newline . Manifest files support three different line terminator types and entries can be split across lines with a line terminator followed by a space .
| 609
| 50
|
156,477
|
private static byte [ ] manifestKeyToBytes ( final String key ) { final byte [ ] bytes = new byte [ key . length ( ) ] ; for ( int i = 0 ; i < key . length ( ) ; i ++ ) { bytes [ i ] = ( byte ) Character . toLowerCase ( key . charAt ( i ) ) ; } return bytes ; }
|
Manifest key to bytes .
| 78
| 6
|
156,478
|
private static boolean keyMatchesAtPosition ( final byte [ ] manifest , final byte [ ] key , final int pos ) { if ( pos + key . length + 1 > manifest . length || manifest [ pos + key . length ] != ' ' ) { return false ; } for ( int i = 0 ; i < key . length ; i ++ ) { // Manifest keys are case insensitive if ( toLowerCase [ manifest [ i + pos ] ] != key [ i ] ) { return false ; } } return true ; }
|
Key matches at position .
| 109
| 5
|
156,479
|
@ Override public String getModuleName ( ) { String moduleName = moduleRef . getName ( ) ; if ( moduleName == null || moduleName . isEmpty ( ) ) { moduleName = moduleNameFromModuleDescriptor ; } return moduleName == null || moduleName . isEmpty ( ) ? null : moduleName ; }
|
Get the module name from the module reference or the module descriptor .
| 71
| 13
|
156,480
|
void addAnnotations ( final AnnotationInfoList packageAnnotations ) { // Currently only class annotations are used in the package-info.class file if ( packageAnnotations != null && ! packageAnnotations . isEmpty ( ) ) { if ( this . annotationInfo == null ) { this . annotationInfo = new AnnotationInfoList ( packageAnnotations ) ; } else { this . annotationInfo . addAll ( packageAnnotations ) ; } } }
|
Add annotations found in a package descriptor classfile .
| 94
| 10
|
156,481
|
public PackageInfoList getChildren ( ) { if ( children == null ) { return PackageInfoList . EMPTY_LIST ; } final PackageInfoList childrenSorted = new PackageInfoList ( children ) ; // Ensure children are sorted CollectionUtils . sortIfNotEmpty ( childrenSorted , new Comparator < PackageInfo > ( ) { @ Override public int compare ( final PackageInfo o1 , final PackageInfo o2 ) { return o1 . name . compareTo ( o2 . name ) ; } } ) ; return childrenSorted ; }
|
The child packages of this package or the empty list if none .
| 116
| 13
|
156,482
|
static String getParentPackageName ( final String packageOrClassName ) { if ( packageOrClassName . isEmpty ( ) ) { return null ; } final int lastDotIdx = packageOrClassName . lastIndexOf ( ' ' ) ; return lastDotIdx < 0 ? "" : packageOrClassName . substring ( 0 , lastDotIdx ) ; }
|
Get the name of the parent package of a parent or the package of the named class .
| 82
| 18
|
156,483
|
public String getPositionInfo ( ) { final int showStart = Math . max ( 0 , position - SHOW_BEFORE ) ; final int showEnd = Math . min ( string . length ( ) , position + SHOW_AFTER ) ; return "before: \"" + JSONUtils . escapeJSONString ( string . substring ( showStart , position ) ) + "\"; after: \"" + JSONUtils . escapeJSONString ( string . substring ( position , showEnd ) ) + "\"; position: " + position + "; token: \"" + token + "\"" ; }
|
Get the parsing context as a string for debugging .
| 128
| 10
|
156,484
|
public void expect ( final char expectedChar ) throws ParseException { final int next = getc ( ) ; if ( next != expectedChar ) { throw new ParseException ( this , "Expected '" + expectedChar + "'; got '" + ( char ) next + "'" ) ; } }
|
Expect the next character .
| 65
| 6
|
156,485
|
public void skipWhitespace ( ) { while ( position < string . length ( ) ) { final char c = string . charAt ( position ) ; if ( c == ' ' || c == ' ' || c == ' ' || c == ' ' ) { position ++ ; } else { break ; } } }
|
Skip whitespace starting at the current position .
| 66
| 9
|
156,486
|
void toJSONString ( final Map < ReferenceEqualityKey < JSONReference > , CharSequence > jsonReferenceToId , final boolean includeNullValuedFields , final int depth , final int indentWidth , final StringBuilder buf ) { final boolean prettyPrint = indentWidth > 0 ; final int n = items . size ( ) ; int numDisplayedFields ; if ( includeNullValuedFields ) { numDisplayedFields = n ; } else { numDisplayedFields = 0 ; for ( final Entry < String , Object > item : items ) { if ( item . getValue ( ) != null ) { numDisplayedFields ++ ; } } } if ( objectId == null && numDisplayedFields == 0 ) { buf . append ( "{}" ) ; } else { buf . append ( prettyPrint ? "{\n" : "{" ) ; if ( objectId != null ) { // id will be non-null if this object does not have an @Id field, but was referenced by // another object (need to include ID_TAG) if ( prettyPrint ) { JSONUtils . indent ( depth + 1 , indentWidth , buf ) ; } buf . append ( ' ' ) ; buf . append ( JSONUtils . ID_KEY ) ; buf . append ( prettyPrint ? "\": " : "\":" ) ; JSONSerializer . jsonValToJSONString ( objectId , jsonReferenceToId , includeNullValuedFields , depth + 1 , indentWidth , buf ) ; if ( numDisplayedFields > 0 ) { buf . append ( ' ' ) ; } if ( prettyPrint ) { buf . append ( ' ' ) ; } } for ( int i = 0 , j = 0 ; i < n ; i ++ ) { final Entry < String , Object > item = items . get ( i ) ; final Object val = item . getValue ( ) ; if ( val != null || includeNullValuedFields ) { final String key = item . getKey ( ) ; if ( key == null ) { // Keys must be quoted, so the unquoted null value cannot be a key // (Should not happen -- JSONParser.parseJSONObject checks for null keys) throw new IllegalArgumentException ( "Cannot serialize JSON object with null key" ) ; } if ( prettyPrint ) { JSONUtils . indent ( depth + 1 , indentWidth , buf ) ; } buf . append ( ' ' ) ; JSONUtils . escapeJSONString ( key , buf ) ; buf . append ( prettyPrint ? "\": " : "\":" ) ; JSONSerializer . jsonValToJSONString ( val , jsonReferenceToId , includeNullValuedFields , depth + 1 , indentWidth , buf ) ; if ( ++ j < numDisplayedFields ) { buf . append ( ' ' ) ; } if ( prettyPrint ) { buf . append ( ' ' ) ; } } } if ( prettyPrint ) { JSONUtils . indent ( depth , indentWidth , buf ) ; } buf . append ( ' ' ) ; } }
|
Serialize this JSONObject to a string .
| 651
| 9
|
156,487
|
private static void handleResourceLoader ( final Object resourceLoader , final ClassLoader classLoader , final ClasspathOrder classpathOrderOut , final ScanSpec scanSpec , final LogNode log ) { if ( resourceLoader == null ) { return ; } // PathResourceLoader has root field, which is a Path object final Object root = ReflectionUtils . getFieldVal ( resourceLoader , "root" , false ) ; // type VirtualFile final File physicalFile = ( File ) ReflectionUtils . invokeMethod ( root , "getPhysicalFile" , false ) ; String path = null ; if ( physicalFile != null ) { final String name = ( String ) ReflectionUtils . invokeMethod ( root , "getName" , false ) ; if ( name != null ) { // getParentFile() removes "contents" directory final File file = new File ( physicalFile . getParentFile ( ) , name ) ; if ( FileUtils . canRead ( file ) ) { path = file . getAbsolutePath ( ) ; } else { // This is an exploded jar or classpath directory path = physicalFile . getAbsolutePath ( ) ; } } else { path = physicalFile . getAbsolutePath ( ) ; } } else { path = ( String ) ReflectionUtils . invokeMethod ( root , "getPathName" , false ) ; if ( path == null ) { // Try Path or File final File file = root instanceof Path ? ( ( Path ) root ) . toFile ( ) : root instanceof File ? ( File ) root : null ; if ( file != null ) { path = file . getAbsolutePath ( ) ; } } } if ( path == null ) { final File file = ( File ) ReflectionUtils . getFieldVal ( resourceLoader , "fileOfJar" , false ) ; if ( file != null ) { path = file . getAbsolutePath ( ) ; } } if ( path != null ) { classpathOrderOut . addClasspathEntry ( path , classLoader , scanSpec , log ) ; } else { if ( log != null ) { log . log ( "Could not determine classpath for ResourceLoader: " + resourceLoader ) ; } } }
|
Handle a resource loader .
| 467
| 5
|
156,488
|
private static void handleRealModule ( final Object module , final Set < Object > visitedModules , final ClassLoader classLoader , final ClasspathOrder classpathOrderOut , final ScanSpec scanSpec , final LogNode log ) { if ( ! visitedModules . add ( module ) ) { // Avoid extracting paths from the same module more than once return ; } ClassLoader moduleLoader = ( ClassLoader ) ReflectionUtils . invokeMethod ( module , "getClassLoader" , false ) ; if ( moduleLoader == null ) { moduleLoader = classLoader ; } // type VFSResourceLoader[] final Object vfsResourceLoaders = ReflectionUtils . invokeMethod ( moduleLoader , "getResourceLoaders" , false ) ; if ( vfsResourceLoaders != null ) { for ( int i = 0 , n = Array . getLength ( vfsResourceLoaders ) ; i < n ; i ++ ) { // type JarFileResourceLoader for jars, VFSResourceLoader for exploded jars, PathResourceLoader // for resource directories, or NativeLibraryResourceLoader for (usually non-existent) native // library "lib/" dirs adjacent to the jarfiles that they were presumably extracted from. final Object resourceLoader = Array . get ( vfsResourceLoaders , i ) ; // Could skip NativeLibraryResourceLoader instances altogether, but testing for their existence // only seems to add about 3% to the total scan time. // if (!resourceLoader.getClass().getSimpleName().equals("NativeLibraryResourceLoader")) { handleResourceLoader ( resourceLoader , moduleLoader , classpathOrderOut , scanSpec , log ) ; //} } } }
|
Handle a module .
| 345
| 4
|
156,489
|
private static boolean matchesPatternList ( final String str , final List < Pattern > patterns ) { if ( patterns != null ) { for ( final Pattern pattern : patterns ) { if ( pattern . matcher ( str ) . matches ( ) ) { return true ; } } } return false ; }
|
Check if a string matches one of the patterns in the provided list .
| 60
| 14
|
156,490
|
private static void quoteList ( final Collection < String > coll , final StringBuilder buf ) { buf . append ( ' ' ) ; boolean first = true ; for ( final String item : coll ) { if ( first ) { first = false ; } else { buf . append ( ", " ) ; } buf . append ( ' ' ) ; for ( int i = 0 ; i < item . length ( ) ; i ++ ) { final char c = item . charAt ( i ) ; if ( c == ' ' ) { buf . append ( "\\\"" ) ; } else { buf . append ( c ) ; } } buf . append ( ' ' ) ; } buf . append ( ' ' ) ; }
|
Quote list .
| 149
| 3
|
156,491
|
@ Override public String getModuleName ( ) { String moduleName = moduleNameFromModuleDescriptor ; if ( moduleName == null || moduleName . isEmpty ( ) ) { moduleName = moduleNameFromManifestFile ; } if ( moduleName == null || moduleName . isEmpty ( ) ) { if ( derivedAutomaticModuleName == null ) { derivedAutomaticModuleName = JarUtils . derivedAutomaticModuleName ( zipFilePath ) ; } moduleName = derivedAutomaticModuleName ; } return moduleName == null || moduleName . isEmpty ( ) ? null : moduleName ; }
|
Get module name from module descriptor or get the automatic module name from the manifest file or derive an automatic module name from the jar name .
| 129
| 27
|
156,492
|
String getZipFilePath ( ) { return packageRootPrefix . isEmpty ( ) ? zipFilePath : zipFilePath + "!/" + packageRootPrefix . substring ( 0 , packageRootPrefix . length ( ) - 1 ) ; }
|
Get the zipfile path .
| 54
| 6
|
156,493
|
private boolean filter ( final String classpathElementPath ) { if ( scanSpec . classpathElementFilters != null ) { for ( final ClasspathElementFilter filter : scanSpec . classpathElementFilters ) { if ( ! filter . includeClasspathElement ( classpathElementPath ) ) { return false ; } } } return true ; }
|
Test to see if a RelativePath has been filtered out by the user .
| 72
| 15
|
156,494
|
boolean addSystemClasspathEntry ( final String pathEntry , final ClassLoader classLoader ) { if ( classpathEntryUniqueResolvedPaths . add ( pathEntry ) ) { order . add ( new SimpleEntry <> ( pathEntry , classLoader ) ) ; return true ; } return false ; }
|
Add a system classpath entry .
| 64
| 7
|
156,495
|
private boolean addClasspathEntry ( final String pathEntry , final ClassLoader classLoader , final ScanSpec scanSpec ) { if ( scanSpec . overrideClasspath == null // && ( SystemJarFinder . getJreLibOrExtJars ( ) . contains ( pathEntry ) || pathEntry . equals ( SystemJarFinder . getJreRtJarPath ( ) ) ) ) { // JRE lib and ext jars are handled separately, so reject them as duplicates if they are // returned by a system classloader return false ; } if ( classpathEntryUniqueResolvedPaths . add ( pathEntry ) ) { order . add ( new SimpleEntry <> ( pathEntry , classLoader ) ) ; return true ; } return false ; }
|
Add a classpath entry .
| 158
| 6
|
156,496
|
public boolean addClasspathEntries ( final String pathStr , final ClassLoader classLoader , final ScanSpec scanSpec , final LogNode log ) { if ( pathStr == null || pathStr . isEmpty ( ) ) { return false ; } else { final String [ ] parts = JarUtils . smartPathSplit ( pathStr ) ; if ( parts . length == 0 ) { return false ; } else { for ( final String pathElement : parts ) { addClasspathEntry ( pathElement , classLoader , scanSpec , log ) ; } return true ; } } }
|
Add classpath entries separated by the system path separator character .
| 120
| 13
|
156,497
|
private static TypeArgument parse ( final Parser parser , final String definingClassName ) throws ParseException { final char peek = parser . peek ( ) ; if ( peek == ' ' ) { parser . expect ( ' ' ) ; return new TypeArgument ( Wildcard . ANY , null ) ; } else if ( peek == ' ' ) { parser . expect ( ' ' ) ; final ReferenceTypeSignature typeSignature = ReferenceTypeSignature . parseReferenceTypeSignature ( parser , definingClassName ) ; if ( typeSignature == null ) { throw new ParseException ( parser , "Missing '+' type bound" ) ; } return new TypeArgument ( Wildcard . EXTENDS , typeSignature ) ; } else if ( peek == ' ' ) { parser . expect ( ' ' ) ; final ReferenceTypeSignature typeSignature = ReferenceTypeSignature . parseReferenceTypeSignature ( parser , definingClassName ) ; if ( typeSignature == null ) { throw new ParseException ( parser , "Missing '-' type bound" ) ; } return new TypeArgument ( Wildcard . SUPER , typeSignature ) ; } else { final ReferenceTypeSignature typeSignature = ReferenceTypeSignature . parseReferenceTypeSignature ( parser , definingClassName ) ; if ( typeSignature == null ) { throw new ParseException ( parser , "Missing type bound" ) ; } return new TypeArgument ( Wildcard . NONE , typeSignature ) ; } }
|
Parse a type argument .
| 316
| 6
|
156,498
|
static List < TypeArgument > parseList ( final Parser parser , final String definingClassName ) throws ParseException { if ( parser . peek ( ) == ' ' ) { parser . expect ( ' ' ) ; final List < TypeArgument > typeArguments = new ArrayList <> ( 2 ) ; while ( parser . peek ( ) != ' ' ) { if ( ! parser . hasMore ( ) ) { throw new ParseException ( parser , "Missing '>'" ) ; } typeArguments . add ( parse ( parser , definingClassName ) ) ; } parser . expect ( ' ' ) ; return typeArguments ; } else { return Collections . emptyList ( ) ; } }
|
Parse a list of type arguments .
| 148
| 8
|
156,499
|
private static void addBundleFile ( final Object bundlefile , final Set < Object > path , final ClassLoader classLoader , final ClasspathOrder classpathOrderOut , final ScanSpec scanSpec , final LogNode log ) { // Don't get stuck in infinite loop if ( bundlefile != null && path . add ( bundlefile ) ) { // type File final Object basefile = ReflectionUtils . getFieldVal ( bundlefile , "basefile" , false ) ; if ( basefile != null ) { boolean foundClassPathElement = false ; for ( final String fieldName : FIELD_NAMES ) { final Object fieldVal = ReflectionUtils . getFieldVal ( bundlefile , fieldName , false ) ; foundClassPathElement = fieldVal != null ; if ( foundClassPathElement ) { // We found the base file and a classpath element, e.g. "bin/" classpathOrderOut . addClasspathEntry ( basefile . toString ( ) + "/" + fieldVal . toString ( ) , classLoader , scanSpec , log ) ; break ; } } if ( ! foundClassPathElement ) { // No classpath element found, just use basefile classpathOrderOut . addClasspathEntry ( basefile . toString ( ) , classLoader , scanSpec , log ) ; } } addBundleFile ( ReflectionUtils . getFieldVal ( bundlefile , "wrapped" , false ) , path , classLoader , classpathOrderOut , scanSpec , log ) ; addBundleFile ( ReflectionUtils . getFieldVal ( bundlefile , "next" , false ) , path , classLoader , classpathOrderOut , scanSpec , log ) ; } }
|
Add the bundle file .
| 363
| 5
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.