idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
126,900
public void visitClassContext ( ClassContext classContext ) { if ( ( collectionClass == null ) || ( iteratorClass == null ) ) { return ; } try { collectionGroups = new ArrayList < > ( ) ; groupToIterator = new HashMap < > ( ) ; loops = new HashMap < > ( 10 ) ; super . visitClassContext ( classContext ) ; } finally { co...
implements the visitor to setup the opcode stack collectionGroups groupToIterator and loops
126,901
public void visitCode ( Code obj ) { collectionGroups . clear ( ) ; groupToIterator . clear ( ) ; loops . clear ( ) ; buildVariableEndScopeMap ( ) ; super . visitCode ( obj ) ; }
implements the visitor to reset the stack collectionGroups groupToIterator and loops
126,902
private boolean breakFollows ( Loop loop , boolean needsPop ) { byte [ ] code = getCode ( ) . getCode ( ) ; int nextPC = getNextPC ( ) ; if ( needsPop ) { int popOp = CodeByteUtils . getbyte ( code , nextPC ++ ) ; if ( popOp != Const . POP ) { return false ; } } int gotoOp = CodeByteUtils . getbyte ( code , nextPC ) ; ...
looks to see if the following instruction is a GOTO preceded by potentially a pop
126,903
private static Comparable < ? > getGroupElement ( OpcodeStack . Item itm ) { Comparable < ? > groupElement = null ; int reg = itm . getRegisterNumber ( ) ; if ( reg >= 0 ) { groupElement = Integer . valueOf ( reg ) ; } else { XField field = itm . getXField ( ) ; if ( field != null ) { int regLoad = itm . getFieldLoaded...
given an register or field look to see if this thing is associated with an already discovered loop
126,904
public void visitCode ( Code obj ) { Method m = getMethod ( ) ; if ( m . isSynthetic ( ) ) { return ; } if ( isEnum && "values" . equals ( m . getName ( ) ) ) { return ; } String sig = m . getSignature ( ) ; int sigPos = sig . indexOf ( ")[" ) ; if ( sigPos < 0 ) { return ; } if ( INITIAL_VALUE . equals ( m . getName (...
overrides the visitor to check to see if the method returns an array and if so resets the stack for this method .
126,905
public void sawOpcode ( int seen ) { String methodInfo = null ; try { stack . precomputation ( this ) ; switch ( seen ) { case Const . INVOKEVIRTUAL : case Const . INVOKEINTERFACE : case Const . INVOKESTATIC : String sig = getSigConstantOperand ( ) ; if ( ! sig . endsWith ( Values . SIG_VOID ) ) { methodInfo = getClass...
implements the visitor to look for return values of common immutable method calls that are thrown away .
126,906
public void visitClassContext ( ClassContext classContext ) { try { classVersion = classContext . getJavaClass ( ) . getMajor ( ) ; if ( classVersion >= Const . MAJOR_1_4 ) { stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } } finally { stack = null ; } }
implements the visitor to make sure the class is at least 1 . 4 and if so continues reseting the opcode stack
126,907
public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; switch ( seen ) { case Const . INVOKESPECIAL : case Const . INVOKESTATIC : case Const . INVOKEINTERFACE : case Const . INVOKEVIRTUAL : String encoding = null ; String className = getClassConstantOperand ( ) ; String methodName = getNameConstan...
implements the visitor to look for method calls that take a parameter that either represents a encoding via a string or takes a Charset . If the method can take both and a string is presented for a standard charset available in jdk 7 and the code is compiled against 7 then report . It also looks for mistakes encodings ...
126,908
private static String replaceNthArgWithCharsetString ( String sig , int stackOffset ) { List < String > arguments = SignatureUtils . getParameterSignatures ( sig ) ; StringBuilder sb = new StringBuilder ( "(" ) ; int argumentIndexToReplace = ( arguments . size ( ) - stackOffset ) - 1 ; for ( int i = 0 ; i < arguments ....
rebuilds a signature replacing a String argument at a specified spot with a Charset parameter .
126,909
@ PublicAPI ( "Used by fb-contrib-eclipse-quickfixes to determine type of fix to apply" ) public static Map < String , Integer > getUnreplaceableCharsetEncodings ( ) { Map < String , Integer > encodings = new HashMap < > ( ( int ) ( UNREPLACEABLE_ENCODING_METHODS . size ( ) * 1.6 ) ) ; for ( Map . Entry < FQMethod , In...
used by external tools lists the method signature checked for for unreplaceable encoding methods
126,910
@ PublicAPI ( "Used by fb-contrib-eclipse-quickfixes to determine type of fix to apply" ) public static Map < String , Integer > getReplaceableCharsetEncodings ( ) { Map < String , Integer > encodings = new HashMap < > ( ( int ) ( REPLACEABLE_ENCODING_METHODS . size ( ) * 1.6 ) ) ; for ( Map . Entry < FQMethod , Intege...
used by external tools lists the method signature checked for for replaceable encoding methods
126,911
public void visitCode ( Code obj ) { Method m = getMethod ( ) ; if ( ( ! m . isStatic ( ) || ! Values . STATIC_INITIALIZER . equals ( m . getName ( ) ) ) && ( ! m . getName ( ) . contains ( "enum constant" ) ) ) { byte [ ] code = obj . getCode ( ) ; if ( code . length >= UNJITABLE_CODE_LENGTH ) { bugReporter . reportBu...
implements the visitor to look at the size of the method . static initializer are ignored as these will only be executed once anyway .
126,912
public boolean prescreen ( Method method ) { BitSet bytecodeSet = getClassContext ( ) . getBytecodeSet ( method ) ; return ( bytecodeSet != null ) && ( bytecodeSet . get ( Const . NEWARRAY ) || bytecodeSet . get ( Const . ANEWARRAY ) ) ; }
looks for methods that contain a NEWARRAY or ANEWARRAY opcodes
126,913
private void processLocalStore ( int seen ) { if ( stack . getStackDepth ( ) == 0 ) { return ; } OpcodeStack . Item itm = stack . getStackItem ( 0 ) ; String sig = itm . getSignature ( ) ; if ( sig . startsWith ( Values . SIG_ARRAY_PREFIX ) ) { int reg = RegisterUtils . getAStoreReg ( this , seen ) ; Integer elReg = ( ...
looks for stores to registers if that store is an array builds a wrapper info for it and stores it in the wrappers collection . If it is a regular store sees if this value came from a wrapper array passed into a method and if so reports it .
126,914
private Integer processArrayElementStore ( ) { if ( stack . getStackDepth ( ) >= 2 ) { OpcodeStack . Item itm = stack . getStackItem ( 2 ) ; int reg = itm . getRegisterNumber ( ) ; if ( reg != - 1 ) { WrapperInfo wi = wrappers . get ( Integer . valueOf ( reg ) ) ; if ( wi != null ) { OpcodeStack . Item elItm = stack . ...
processes a store to an array element to see if this array is being used as a wrapper array and if so records the register that is stored within it .
126,915
private void processMethodCall ( ) { if ( "invoke" . equals ( getNameConstantOperand ( ) ) && "java/lang/reflect/Method" . equals ( getClassConstantOperand ( ) ) ) { return ; } String sig = getSigConstantOperand ( ) ; List < String > args = SignatureUtils . getParameterSignatures ( sig ) ; if ( stack . getStackDepth ( ...
processes a method call looking for parameters that are arrays . If this array was seen earlier as a simple wrapping array then it marks it as being having been used as a parameter .
126,916
private boolean isCallingOnThis ( String sig ) { if ( getMethod ( ) . isStatic ( ) ) { return false ; } int numParameters = SignatureUtils . getNumParameters ( sig ) ; if ( stack . getStackDepth ( ) <= numParameters ) { return false ; } OpcodeStack . Item item = stack . getStackItem ( numParameters ) ; return item . ge...
checks to see if an instance method is called on the this object
126,917
public void report ( ) { for ( Map . Entry < FQMethod , MethodInfo > entry : Statistics . getStatistics ( ) ) { MethodInfo mi = entry . getValue ( ) ; int declaredAccess = mi . getDeclaredAccess ( ) ; if ( ( declaredAccess & Const . ACC_PRIVATE ) != 0 ) { continue ; } if ( mi . wasCalledPublicly ( ) || ! mi . wasCalled...
after collecting all method calls build a report of all methods that have been called but in a way that is less permissive then is defined .
126,918
private boolean isConstrainedByInterface ( FQMethod fqMethod ) { try { JavaClass fqCls = Repository . lookupClass ( fqMethod . getClassName ( ) ) ; if ( fqCls . isInterface ( ) ) { return true ; } for ( JavaClass inf : fqCls . getAllInterfaces ( ) ) { for ( Method infMethod : inf . getMethods ( ) ) { if ( infMethod . g...
looks to see if this method is an implementation of a method in an interface including generic specified interface methods .
126,919
private boolean isDerived ( JavaClass fqCls , FQMethod key ) { try { for ( JavaClass infCls : fqCls . getInterfaces ( ) ) { for ( Method infMethod : infCls . getMethods ( ) ) { if ( key . getMethodName ( ) . equals ( infMethod . getName ( ) ) ) { if ( infMethod . getGenericSignature ( ) != null ) { if ( SignatureUtils ...
looks to see if this method described by key is derived from a superclass or interface
126,920
public void visitCode ( Code obj ) { stack . resetForMethodEntry ( this ) ; localSpecialObjects . clear ( ) ; sawTernary = false ; super . visitCode ( obj ) ; for ( Integer pc : localSpecialObjects . values ( ) ) { bugReporter . reportBug ( makeLocalBugInstance ( ) . addClass ( this ) . addMethod ( this ) . addSourceLi...
overrides the visitor reset the stack
126,921
protected void processMethodParms ( ) { String sig = getSigConstantOperand ( ) ; int numParms = SignatureUtils . getNumParameters ( sig ) ; if ( ( numParms > 0 ) && ( stack . getStackDepth ( ) >= numParms ) ) { for ( int i = 0 ; i < numParms ; i ++ ) { clearUserValue ( stack . getStackItem ( i ) ) ; } } }
Checks to see if any of the locals or fields that we are tracking are passed into another method . If they are we clear out our tracking of them because we can t easily track their progress into the method .
126,922
public void visitClassContext ( ClassContext classContext ) { try { guiInterfaces = new HashSet < > ( ) ; JavaClass cls = classContext . getJavaClass ( ) ; JavaClass [ ] infs = cls . getAllInterfaces ( ) ; for ( JavaClass inf : infs ) { String name = inf . getClassName ( ) ; if ( ( name . startsWith ( "java.awt." ) || ...
overrides the visitor to reset look for gui interfaces
126,923
public void visitAfter ( JavaClass obj ) { isListenerMethod = true ; for ( Code l : listenerCode . keySet ( ) ) { try { super . visitCode ( l ) ; } catch ( StopOpcodeParsingException e ) { } } super . visitAfter ( obj ) ; }
overrides the visitor to visit all of the collected listener methods
126,924
public void visitMethod ( Method obj ) { methodName = obj . getName ( ) ; methodSig = obj . getSignature ( ) ; }
overrides the visitor collect method info
126,925
public void visitCode ( Code obj ) { try { for ( JavaClass inf : guiInterfaces ) { Method [ ] methods = inf . getMethods ( ) ; for ( Method m : methods ) { if ( m . getName ( ) . equals ( methodName ) && m . getSignature ( ) . equals ( methodSig ) ) { listenerCode . put ( obj , this . getMethod ( ) ) ; return ; } } } i...
overrides the visitor to segregate method into two those that implement listeners and those that don t . The ones that don t are processed first .
126,926
public void sawOpcode ( int seen ) { if ( ( seen == Const . INVOKEINTERFACE ) || ( seen == Const . INVOKEVIRTUAL ) || ( seen == Const . INVOKESPECIAL ) || ( seen == Const . INVOKESTATIC ) ) { String clsName = getClassConstantOperand ( ) ; String mName = getNameConstantOperand ( ) ; String methodInfo = clsName + ':' + m...
overrides the visitor to look for the execution of expensive calls
126,927
public static void println ( int pc , Object obj ) { out . printf ( "[PC:%d] %s%n" , Integer . valueOf ( pc ) , obj ) ; }
Like println but will print PC if it s passed in
126,928
public static boolean isValidLineNumber ( Code obj , int pc ) { LineNumberTable lnt = obj . getLineNumberTable ( ) ; if ( lnt == null ) return true ; LineNumber [ ] lineNumbers = lnt . getLineNumberTable ( ) ; if ( lineNumbers == null ) return true ; int lo = 0 ; int hi = lineNumbers . length - 1 ; int mid = 0 ; int li...
returns whether the pc is at a line number that also appears for a another byte code offset later on in the method . If this occurs we are in a jdk6 finally replicated block and so don t report this . If the code has no line number table then just report it .
126,929
public void visitClassContext ( ClassContext classContext ) { try { if ( ( collectionClass != null ) && ( mapClass != null ) ) { collectionFields = new HashMap < > ( ) ; aliases = new HashMap < > ( ) ; stack = new OpcodeStack ( ) ; JavaClass cls = classContext . getJavaClass ( ) ; className = cls . getClassName ( ) ; s...
implements the visitor to clear the collectionFields and stack and to report collections that remain unmodified out of clinit or init
126,930
public void visitField ( Field obj ) { if ( obj . isPrivate ( ) ) { String signature = obj . getSignature ( ) ; if ( signature . startsWith ( Values . SIG_QUALIFIED_CLASS_PREFIX ) ) { try { JavaClass cls = Repository . lookupClass ( SignatureUtils . stripSignature ( signature ) ) ; if ( cls . implementationOf ( collect...
implements the visitor to find collection fields
126,931
public void visitCode ( Code obj ) { if ( collectionFields . isEmpty ( ) ) { return ; } aliases . clear ( ) ; String methodName = getMethodName ( ) ; if ( Values . STATIC_INITIALIZER . equals ( methodName ) ) { state = State . IN_CLINIT ; } else if ( Values . CONSTRUCTOR . equals ( methodName ) ) { state = State . IN_I...
implements the visitor to set the state based on the type of method being parsed
126,932
public void sawOpcode ( int seen ) { switch ( state ) { case IN_CLINIT : sawCLInitOpcode ( seen ) ; break ; case IN_INIT : sawInitOpcode ( seen ) ; break ; case IN_METHOD : sawMethodOpcode ( seen ) ; break ; } }
implements the visitor to call the approriate visitor based on state
126,933
private void sawMethodOpcode ( int seen ) { boolean isSyncCollection = false ; try { stack . mergeJumps ( this ) ; isSyncCollection = isSyncCollectionCreation ( seen ) ; switch ( seen ) { case Const . INVOKEVIRTUAL : case Const . INVOKEINTERFACE : String methodName = getNameConstantOperand ( ) ; if ( modifyingMethods ....
handles regular methods by looking for methods on collections that are modifying and removes those collections from the ones under review
126,934
private boolean isSyncCollectionCreation ( int seen ) { if ( seen == Const . INVOKESPECIAL ) { if ( Values . CONSTRUCTOR . equals ( getNameConstantOperand ( ) ) ) { return ( syncCollections . contains ( getClassConstantOperand ( ) ) ) ; } } else if ( ( seen == Const . INVOKESTATIC ) && "java/util/Collections" . equals ...
returns whether this instruction is creating a synchronized collection
126,935
private void processCollectionStore ( ) { String fieldClassName = getDottedClassConstantOperand ( ) ; if ( fieldClassName . equals ( className ) && ( stack . getStackDepth ( ) > 0 ) ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; if ( item . getUserValue ( ) != null ) { String fieldName = getNameConstantOper...
sets the source line annotation of a store to a collection if that collection is synchronized .
126,936
private void removeCollectionParameters ( ) { int parmCount = SignatureUtils . getNumParameters ( getSigConstantOperand ( ) ) ; if ( stack . getStackDepth ( ) >= parmCount ) { for ( int i = 0 ; i < parmCount ; i ++ ) { OpcodeStack . Item item = stack . getStackItem ( i ) ; XField field = item . getXField ( ) ; if ( fie...
removes collection fields that are passed to other methods as arguments
126,937
public void visitClassContext ( ClassContext classContext ) { try { bloatableCandidates = new HashMap < > ( ) ; bloatableFields = new HashMap < > ( ) ; threadLocalNonStaticFields = new HashSet < > ( ) ; userValues = new HashMap < > ( ) ; jaxbContextRegs = new HashMap < > ( ) ; parseFields ( classContext ) ; stack = new...
collects static fields that are likely bloatable objects and if found allows the visitor to proceed at the end report all leftover fields
126,938
public void visitClassContext ( ClassContext clsContext ) { try { stack = new OpcodeStack ( ) ; super . visitClassContext ( clsContext ) ; } finally { stack = null ; } }
overrides the visitor to setup the opcode stack
126,939
public void visitCode ( Code obj ) { stack . resetForMethodEntry ( this ) ; conditionalTarget = - 1 ; sawMethodWeight = 0 ; super . visitCode ( obj ) ; }
overrides the visitor to reset the opcode stack and initialize vars
126,940
public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; if ( isSerializable ( cls ) ) { JavaClass superCls = cls . getSuperClass ( ) ; if ( ! isSerializable ( superCls ) && hasSerializableFields ( superCls ) && ! hasSerializingMethods ( cls ) ) { bugReporter...
implements the visitor to look for classes that are serializable and are derived from non serializable classes and don t either implement methods in Externalizable or Serializable to save parent class fields .
126,941
private static boolean isSerializable ( JavaClass cls ) throws ClassNotFoundException { JavaClass [ ] infs = cls . getAllInterfaces ( ) ; for ( JavaClass inf : infs ) { String clsName = inf . getClassName ( ) ; if ( "java.io.Serializable" . equals ( clsName ) || "java.io.Externalizable" . equals ( clsName ) ) { return ...
returns if the class implements Serializable or Externalizable
126,942
private static boolean hasSerializableFields ( JavaClass cls ) { Field [ ] fields = cls . getFields ( ) ; for ( Field f : fields ) { if ( ! f . isStatic ( ) && ! f . isTransient ( ) && ! f . isSynthetic ( ) ) { return true ; } } return false ; }
looks for fields that are candidates for serialization
126,943
private static boolean hasSerializingMethods ( JavaClass cls ) { Method [ ] methods = cls . getMethods ( ) ; for ( Method m : methods ) { if ( ! m . isStatic ( ) ) { String methodName = m . getName ( ) ; String methodSig = m . getSignature ( ) ; if ( "writeObject" . equals ( methodName ) && SIG_OBJECT_OUTPUT_STREAM_TO_...
looks to see if this class implements method described by Serializable or Externalizable
126,944
public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( seen == Const . INVOKESTATIC ) { String clsName = getClassConstantOperand ( ) ; if ( "java/util/Arrays" . equals ( clsName ) ) { String methodName = getNameConstantOperand ( ) ; if ( "asList" . equals ( methodName ) && ( stack . getStackD...
implements the visitor to find calls to Arrays . asList with a primitive array
126,945
public void visitCode ( Code obj ) { state = State . SEEN_NOTHING ; beanReference1 = null ; beanReference2 = null ; propName = null ; propType = null ; sawField = false ; super . visitCode ( obj ) ; }
overrides the visitor to reset the state to SEEN_NOTHING and clear the beanReference propName and propType
126,946
public void sawOpcode ( int seen ) { boolean reset = true ; switch ( state ) { case SEEN_NOTHING : reset = sawOpcodeAfterNothing ( seen ) ; break ; case SEEN_ALOAD : reset = sawOpcodeAfterLoad ( seen ) ; break ; case SEEN_GETFIELD : reset = sawOpcodeAfterGetField ( seen ) ; break ; case SEEN_DUAL_LOADS : reset = sawOpc...
overrides the visitor to look for a setXXX with the value returned from a getXXX using the same base object .
126,947
public void visitClassContext ( ClassContext classContext ) { try { if ( ( invocationHandlerClass != null ) && classContext . getJavaClass ( ) . implementationOf ( invocationHandlerClass ) ) { return ; } iConst0Looped = new BitSet ( ) ; stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } catch ...
implements the visitor to create and clear the const0loop set
126,948
private static boolean isArrayFromUbiquitousMethod ( OpcodeStack . Item item ) { XMethod method = item . getReturnValueOf ( ) ; if ( method == null ) { return false ; } FQMethod methodDesc = new FQMethod ( method . getClassName ( ) . replace ( '.' , '/' ) , method . getName ( ) , method . getSignature ( ) ) ; return ub...
returns whether the array item was returned from a common method that the user can t do anything about and so don t report CLI in this case .
126,949
public void visitClassContext ( ClassContext classContext ) { try { unusedParms = new BitSet ( ) ; regToParm = new HashMap < > ( ) ; stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; regToParm = null ; unusedParms . clear ( ) ; } }
implements the visitor to create parm bitset
126,950
public void visitCode ( Code obj ) { unusedParms . clear ( ) ; regToParm . clear ( ) ; stack . resetForMethodEntry ( this ) ; Method m = getMethod ( ) ; String methodName = m . getName ( ) ; if ( IGNORE_METHODS . contains ( methodName ) ) { return ; } int accessFlags = m . getAccessFlags ( ) ; if ( ( ( accessFlags & ( ...
implements the visitor to clear the parm set and check for potential methods
126,951
public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( OpcodeUtils . isStore ( seen ) || OpcodeUtils . isLoad ( seen ) ) { int reg = getRegisterOperand ( ) ; unusedParms . clear ( reg ) ; } else if ( OpcodeUtils . isReturn ( seen ) && ( stack . getStackDepth ( ) > 0 ) ) { OpcodeStack . Item i...
implements the visitor to look for usage of parmeter registers .
126,952
public static String getPackageName ( final String className ) { int dotPos = className . lastIndexOf ( '.' ) ; if ( dotPos < 0 ) { return "" ; } return className . substring ( 0 , dotPos ) ; }
parses the package name from a fully qualified class name
126,953
public static boolean similarPackages ( String packName1 , String packName2 , int depth ) { if ( depth == 0 ) { return true ; } String dottedPackName1 = packName1 . replace ( '/' , '.' ) ; String dottedPackName2 = packName2 . replace ( '/' , '.' ) ; int dot1 = dottedPackName1 . indexOf ( '.' ) ; int dot2 = dottedPackNa...
returns whether or not the two packages have the same first depth parts if they exist
126,954
public static String getTypeCodeSignature ( int typeCode ) { String signature = Values . PRIMITIVE_TYPE_CODE_SIGS . get ( ( byte ) typeCode ) ; return signature == null ? Values . SIG_JAVA_LANG_OBJECT : signature ; }
converts a primitive type code to a signature
126,955
public static Map < Integer , String > getParameterSlotAndSignatures ( boolean methodIsStatic , String methodSignature ) { int start = methodSignature . indexOf ( '(' ) + 1 ; int limit = methodSignature . lastIndexOf ( ')' ) ; if ( ( limit - start ) == 0 ) { return Collections . emptyMap ( ) ; } Map < Integer , String ...
returns a Map that represents the type of the parameter in slot x
126,956
public static List < String > getParameterSignatures ( String methodSignature ) { int start = methodSignature . indexOf ( '(' ) + 1 ; int limit = methodSignature . lastIndexOf ( ')' ) ; if ( ( limit - start ) == 0 ) { return Collections . emptyList ( ) ; } List < String > parmSignatures = new ArrayList < > ( ) ; int si...
returns a List of parameter signatures
126,957
public static String getReturnSignature ( String methodSig ) { int parenPos = methodSig . indexOf ( ')' ) ; if ( parenPos < 0 ) { return "?" ; } return methodSig . substring ( parenPos + 1 ) ; }
gets the return type signature from a method signature
126,958
public static int getNumParameters ( String methodSignature ) { int start = methodSignature . indexOf ( '(' ) + 1 ; int limit = methodSignature . lastIndexOf ( ')' ) ; if ( ( limit - start ) == 0 ) { return 0 ; } int numParms = 0 ; for ( int i = start ; i < limit ; i ++ ) { if ( ! methodSignature . startsWith ( Values ...
returns the number of parameters in this method signature
126,959
public static int getFirstRegisterSlot ( Method m ) { Type [ ] parms = m . getArgumentTypes ( ) ; int first = m . isStatic ( ) ? 0 : 1 ; for ( Type t : parms ) { first += getSignatureSize ( t . getSignature ( ) ) ; } return first ; }
returns the first open register slot after parameters
126,960
public static String toArraySignature ( String typeName ) { String sig = classToSignature ( typeName ) ; if ( ( sig == null ) || ( sig . length ( ) == 0 ) ) { return sig ; } return Values . SIG_ARRAY_PREFIX + sig ; }
Converts a type name into an array signature . Accepts slashed or dotted classnames or type signatures .
126,961
private static boolean isWonkyEclipseSignature ( String sig , int startIndex ) { return ( sig . length ( ) > startIndex ) && ( ECLIPSE_WEIRD_SIG_CHARS . indexOf ( sig . charAt ( startIndex ) ) >= 0 ) ; }
Eclipse makes weird class signatures .
126,962
public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; int major = cls . getMajor ( ) ; if ( major >= Const . MAJOR_1_5 ) { stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } } finally { stack = null ; } }
implements the visitor to check for class file version 1 . 5 or better
126,963
public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( ( seen != Const . INVOKEVIRTUAL ) || ! "wait" . equals ( getNameConstantOperand ( ) ) || stack . getStackDepth ( ) == 0 ) { return ; } JavaClass cls = stack . getStackItem ( 0 ) . getJavaClass ( ) ; if ( cls != null ) { String clsName = c...
implements the visitor to look for calls to wait on java . util . concurrent classes that define await .
126,964
public void sawOpcode ( int seen ) { String strCon = null ; try { stack . precomputation ( this ) ; if ( seen == Const . INVOKESPECIAL ) { String clsName = getClassConstantOperand ( ) ; if ( SignatureUtils . isPlainStringConvertableClass ( clsName ) ) { String methodName = getNameConstantOperand ( ) ; String methodSig ...
overrides the visitor to find String concatenations including xml strings
126,965
public void sawOpcode ( int seen ) { try { switch ( state ) { case SAW_NOTHING : sawOpcodeAfterNothing ( seen ) ; break ; case SAW_EQUALS : sawOpcodeAfterEquals ( seen ) ; break ; case SAW_IFEQ : sawOpcodeAfterBranch ( seen ) ; break ; } processLoad ( seen ) ; processLoop ( seen ) ; } finally { stack . sawOpcode ( this...
implements the visitor to find continuations after finding a search result in a loop .
126,966
public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; graphicsRegs = new HashMap < Integer , Integer > ( 5 ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; graphicsRegs = null ; } }
overrides the visitor to set up the opcode stack
126,967
public void visitCode ( Code obj ) { try { Method m = getMethod ( ) ; if ( m . isSynthetic ( ) ) { return ; } if ( m . isStatic ( ) || m . isPrivate ( ) || Values . CONSTRUCTOR . equals ( m . getName ( ) ) ) { parmSigs = SignatureUtils . getParameterSlotAndSignatures ( m . isStatic ( ) , m . getSignature ( ) ) ; if ( !...
implements the visitor to see if the method has parameters
126,968
public void sawOpcode ( int seen ) { if ( downwardBranchTarget == - 1 ) { switch ( state ) { case SAW_NOTHING : sawOpcodeAfterNothing ( seen ) ; break ; case SAW_LOAD : sawOpcodeAfterLoad ( seen ) ; break ; case SAW_CHECKCAST : sawOpcodeAfterCheckCast ( seen ) ; break ; } int insTarget = - 1 ; if ( ( ( seen >= Const . ...
implements the visitor to look for check casts of parameters to more specific types
126,969
public void visitClassContext ( ClassContext classContext ) { try { currentClass = classContext . getJavaClass ( ) ; stack = new OpcodeStack ( ) ; returnTypes = new HashMap < > ( ) ; super . visitClassContext ( classContext ) ; } finally { currentClass = null ; stack = null ; returnTypes = null ; } }
implements the visitor to create and destroy the stack and return types
126,970
public void visitCode ( Code obj ) { Method m = getMethod ( ) ; if ( m . isSynthetic ( ) ) { return ; } String signature = m . getSignature ( ) ; if ( ! signature . endsWith ( ")Ljava/lang/Object;" ) ) { return ; } stack . resetForMethodEntry ( this ) ; returnTypes . clear ( ) ; super . visitCode ( obj ) ; if ( returnT...
implements the visitor to see if the method returns Object and if the method is defined in a superclass or interface .
126,971
public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( ( seen == Const . ARETURN ) && ( stack . getStackDepth ( ) > 0 ) ) { OpcodeStack . Item itm = stack . getStackItem ( 0 ) ; if ( ! itm . isNull ( ) ) { returnTypes . put ( itm . getJavaClass ( ) , Integer . valueOf ( getPC ( ) ) ) ; } } } ...
implements the visitor to find return values where the types of objects returned from the method are related only by object .
126,972
private static JavaClass findCommonType ( Set < JavaClass > classes ) throws ClassNotFoundException { Set < JavaClass > possibleCommonTypes = new HashSet < > ( ) ; boolean populate = true ; for ( JavaClass cls : classes ) { if ( cls == null ) { return null ; } if ( Values . SLASHED_JAVA_LANG_OBJECT . equals ( cls . get...
looks for a common superclass or interface for all the passed in types
126,973
public void visitCode ( Code obj ) { state = State . SAW_NOTHING ; stack . resetForMethodEntry ( this ) ; super . visitCode ( obj ) ; }
overrides the visitor to reset the state and reset the opcode stack
126,974
public void sawOpcode ( int seen ) { int pc = 0 ; try { stack . precomputation ( this ) ; switch ( state ) { case SAW_NOTHING : pc = sawOpcodeAfterNothing ( seen ) ; break ; case SAW_CTOR : if ( ( seen == Const . POP ) || ( seen == Const . RETURN ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . SEC_SI...
overrides the visitor to look for constructors who s value is popped off the stack and not assigned before the pop of the value or if a return is issued with that object still on the stack .
126,975
public void visitClassContext ( final ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; packageName = cls . getPackageName ( ) ; clsName = cls . getClassName ( ) ; parentClassName = cls . getSuperclassName ( ) ; stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext )...
overrides the visitor to collect package and class names
126,976
public void visitMethod ( final Method obj ) { methodName = obj . getName ( ) ; methodIsStatic = obj . isStatic ( ) ; }
overrides the visitor to check whether the method is static
126,977
@ SuppressWarnings ( "unchecked" ) public void visitCode ( final Code obj ) { stack . resetForMethodEntry ( this ) ; thisClsAccessCount = 0 ; if ( Values . STATIC_INITIALIZER . equals ( methodName ) ) { return ; } clsAccessCount = new HashMap < > ( ) ; super . visitCode ( obj ) ; if ( clsAccessCount . isEmpty ( ) ) { r...
overrides the visitor to look for the method that uses another class the most and if it exceeds the threshold reports it
126,978
public void sawOpcode ( final int seen ) { try { stack . precomputation ( this ) ; if ( OpcodeUtils . isStandardInvoke ( seen ) ) { String calledClass = getDottedClassConstantOperand ( ) ; if ( seen == Const . INVOKEINTERFACE ) { int parmCount = SignatureUtils . getNumParameters ( this . getSigConstantOperand ( ) ) ; i...
overrides the visitor to look for method calls and populate a class access count map based on the owning class of methods called .
126,979
private boolean implementsCommonInterface ( String name ) { try { JavaClass cls = Repository . lookupClass ( name ) ; JavaClass [ ] infs = cls . getAllInterfaces ( ) ; for ( JavaClass inf : infs ) { String infName = inf . getClassName ( ) ; if ( ignorableInterfaces . contains ( infName ) ) { continue ; } if ( infName ....
return whether or not a class implements a common or marker interface
126,980
private boolean countClassAccess ( final int classAtStackIndex ) { String calledClass ; try { if ( stack . getStackDepth ( ) > classAtStackIndex ) { OpcodeStack . Item itm = stack . getStackItem ( classAtStackIndex ) ; JavaClass cls = itm . getJavaClass ( ) ; if ( cls != null ) { calledClass = cls . getClassName ( ) ; ...
increment the count of class access of the class on the stack
126,981
private void countClassAccess ( final String calledClass ) { if ( calledClass . equals ( clsName ) || isAssociatedClass ( calledClass ) ) { if ( getPrevOpcode ( 1 ) != Const . ALOAD_0 ) { thisClsAccessCount ++ ; } } else { String calledPackage = SignatureUtils . getPackageName ( calledClass ) ; if ( SignatureUtils . si...
increment the count of class access of the specified class if it is in a similar package to the caller and is not general purpose
126,982
private void addLineNumber ( BitSet lineNumbers ) { LineNumberTable lnt = getCode ( ) . getLineNumberTable ( ) ; if ( lnt == null ) { lineNumbers . set ( 0 ) ; } else { int line = lnt . getSourceLine ( getPC ( ) ) ; if ( line < 0 ) { lineNumbers . set ( lineNumbers . size ( ) ) ; } else { lineNumbers . set ( line ) ; }...
add the current line number to a set of line numbers
126,983
@ edu . umd . cs . findbugs . annotations . SuppressFBWarnings ( value = "EXS_EXCEPTION_SOFTENING_RETURN_FALSE" , justification = "No other simple way to determine whether class exists" ) private boolean generalPurpose ( final String className ) { if ( className . startsWith ( "java." ) || className . startsWith ( "jav...
checks to see if the specified class is a built in class or implements a simple interface
126,984
public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; localClassTypes = new HashMap < > ( ) ; fieldClassTypes = new HashMap < > ( ) ; JavaClass cls = classContext . getJavaClass ( ) ; Method staticInit = findStaticInitializer ( cls ) ; if ( staticInit != null ) { setupVisitor...
implements the visitor to create the stack and local and field maps for Class arrays to be used for getting the reflection method
126,985
private static Method findStaticInitializer ( JavaClass cls ) { Method [ ] methods = cls . getMethods ( ) ; for ( Method m : methods ) { if ( Values . STATIC_INITIALIZER . equals ( m . getName ( ) ) ) { return m ; } } return null ; }
finds the method that is the static initializer for the class
126,986
public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; ifBlocks = new IfBlocks ( ) ; gotoBranchPCs = new BitSet ( ) ; casePositions = new BitSet ( ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; ifBlocks = null ; catchPCs = null ; gotoBranchPCs = nu...
implements the visitor to reset the opcode stack and initialize if tracking collections
126,987
private boolean isResetOp ( int seen ) { return resetOps . get ( seen ) || OpcodeUtils . isStore ( seen ) || OpcodeUtils . isReturn ( seen ) || ( ( OpcodeUtils . isInvoke ( seen ) && getSigConstantOperand ( ) . endsWith ( ")V" ) ) || ( isBranch ( seen ) && ( getBranchOffset ( ) < 0 ) ) ) ; }
determines if this opcode couldn t be part of a conditional expression or at least is very unlikely to be so .
126,988
public void visitCode ( Code obj ) { try { stack . resetForMethodEntry ( this ) ; reportedType = ImmutabilityType . UNKNOWN ; super . visitCode ( obj ) ; } catch ( StopOpcodeParsingException e ) { } }
overrides the visitor to reset the opcode stack and reset the reported immutability of the method
126,989
public void sawOpcode ( int seen ) { ImmutabilityType imType = null ; try { stack . precomputation ( this ) ; switch ( seen ) { case Const . INVOKESTATIC : case Const . INVOKEINTERFACE : case Const . INVOKESPECIAL : case Const . INVOKEVIRTUAL : { String className = getClassConstantOperand ( ) ; String methodName = getN...
overrides the visitor to find method mutations on collections that have previously been determined to have been created as immutable collections
126,990
public String encrypt ( String data ) throws UnsupportedEncodingException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidAlgorithmParameterException , InvalidKeyException , InvalidKeySpecException , BadPaddingException , IllegalBlockSizeException { if ( data == null ) return null ; SecretKey secretKey = g...
Encrypt a String
126,991
public void encryptAsync ( final String data , final Callback callback ) { if ( callback == null ) return ; new Thread ( new Runnable ( ) { public void run ( ) { try { String encrypt = encrypt ( data ) ; if ( encrypt == null ) { callback . onError ( new Exception ( "Encrypt return null, it normally occurs when you send...
This is a sugar method that calls encrypt method in background it is a good idea to use this one instead the default method because encryption can take several time and with this method the process occurs in a AsyncTask other advantage is the Callback with separated methods one for success and other for the exception
126,992
public String decrypt ( String data ) throws UnsupportedEncodingException , NoSuchAlgorithmException , InvalidKeySpecException , NoSuchPaddingException , InvalidAlgorithmParameterException , InvalidKeyException , BadPaddingException , IllegalBlockSizeException { if ( data == null ) return null ; byte [ ] dataBytes = Ba...
Decrypt a String
126,993
public void decryptAsync ( final String data , final Callback callback ) { if ( callback == null ) return ; new Thread ( new Runnable ( ) { public void run ( ) { try { String decrypt = decrypt ( data ) ; if ( decrypt == null ) { callback . onError ( new Exception ( "Decrypt return null, it normally occurs when you send...
This is a sugar method that calls decrypt method in background it is a good idea to use this one instead the default method because decryption can take several time and with this method the process occurs in a AsyncTask other advantage is the Callback with separated methods one for success and other for the exception
126,994
private SecretKey getSecretKey ( char [ ] key ) throws NoSuchAlgorithmException , UnsupportedEncodingException , InvalidKeySpecException { SecretKeyFactory factory = SecretKeyFactory . getInstance ( mBuilder . getSecretKeyType ( ) ) ; KeySpec spec = new PBEKeySpec ( key , mBuilder . getSalt ( ) . getBytes ( mBuilder . ...
creates a 128bit salted aes key
126,995
private char [ ] hashTheKey ( String key ) throws UnsupportedEncodingException , NoSuchAlgorithmException { MessageDigest messageDigest = MessageDigest . getInstance ( mBuilder . getDigestAlgorithm ( ) ) ; messageDigest . update ( key . getBytes ( mBuilder . getCharsetName ( ) ) ) ; return Base64 . encodeToString ( mes...
takes in a simple string and performs an sha1 hash that is 128 bits long ... we then base64 encode it and return the char array
126,996
private void renderTag ( Tag tag , StringBuilder buffer ) { buffer . append ( tag . name ( ) ) . append ( ' ' ) ; if ( ( tag instanceof ParamTag ) && ( ( ParamTag ) tag ) . isTypeParameter ( ) ) { ParamTag paramTag = ( ParamTag ) tag ; buffer . append ( "<" + paramTag . parameterName ( ) + ">" ) ; String text = paramTa...
Renders a document tag in the standard way .
126,997
private String render ( String input , boolean inline ) { if ( input . trim ( ) . isEmpty ( ) ) { return "" ; } options . setDocType ( inline ? INLINE_DOCTYPE : null ) ; return asciidoctor . render ( cleanJavadocInput ( input ) , options ) ; }
Renders the input using Asciidoctor .
126,998
@ SuppressWarnings ( "UnusedDeclaration" ) public static boolean validOptions ( String [ ] [ ] options , DocErrorReporter errorReporter ) { return validOptions ( options , errorReporter , new StandardAdapter ( ) ) ; }
Processes the input options by delegating to the standard handler .
126,999
public boolean render ( RootDoc rootDoc , DocletRenderer renderer ) { if ( ! processOverview ( rootDoc , renderer ) ) { return false ; } Set < PackageDoc > packages = new HashSet < PackageDoc > ( ) ; for ( ClassDoc doc : rootDoc . classes ( ) ) { packages . add ( doc . containingPackage ( ) ) ; renderClass ( doc , rend...
Renders a RootDoc s contents .