idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
3,200 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( seen == Const . INVOKEINTERFACE ) { KeyType type = isKeyAccessMethod ( seen ) ; if ( type != null ) { int numParms = SignatureUtils . getNumParameters ( getSigConstantOperand ( ) ) ; if ( stack . getStackDepth ( ) >= numParms ) { OpcodeSt... | implements the visitor to look for calls to HttpServletRequest . getParameter and collect what the name of the key is . |
3,201 | public void report ( ) { for ( Map . Entry < KeyType , Map < String , Map < String , List < SourceInfo > > > > entry : parmInfo . entrySet ( ) ) { KeyType type = entry . getKey ( ) ; Map < String , Map < String , List < SourceInfo > > > typeMap = entry . getValue ( ) ; for ( Map < String , List < SourceInfo > > parmCas... | implements the visitor to look for the collected parm names and look for duplicates that are different in casing only . |
3,202 | public void visitClassContext ( ClassContext classContext ) { try { branchTargets = new BitSet ( ) ; catchTargets = new BitSet ( ) ; stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } finally { branchTargets = null ; catchTargets = null ; stack = null ; } } | implements the visitor to create and clear the branchTargets |
3,203 | public void visitCode ( Code obj ) { Method m = getMethod ( ) ; String sig = m . getSignature ( ) ; if ( ! Values . SIG_VOID . equals ( SignatureUtils . getReturnSignature ( sig ) ) ) { state = State . SEEN_NOTHING ; branchTargets . clear ( ) ; CodeException [ ] ces = obj . getExceptionTable ( ) ; catchTargets . clear ... | implements the visitor to make sure method returns a value and then clears the targets |
3,204 | public void sawOpcode ( int seen ) { int lhsReg = - 1 ; try { stack . precomputation ( this ) ; switch ( state ) { case SEEN_NOTHING : if ( ! catchTargets . get ( getPC ( ) ) && lookForStore ( seen ) && ( stack . getStackDepth ( ) >= 1 ) ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; Integer reg = ( Integer... | implements the visitor to look for store of registers immediately before returns of that register |
3,205 | private boolean lookForStore ( int seen ) { if ( ! OpcodeUtils . isStore ( seen ) ) { return false ; } storeReg = RegisterUtils . getStoreReg ( this , seen ) ; return true ; } | checks if the current opcode is a store if so saves the register |
3,206 | private boolean lookForLoad ( int seen ) { int loadReg ; if ( ! OpcodeUtils . isLoad ( seen ) ) { return false ; } loadReg = RegisterUtils . getLoadReg ( this , seen ) ; return ( storeReg == loadReg ) ; } | looks for a load of the register that was just stored |
3,207 | public void visitCode ( Code obj ) { try { String signature = SignatureUtils . getReturnSignature ( getMethod ( ) . getSignature ( ) ) ; if ( signature . startsWith ( Values . SIG_QUALIFIED_CLASS_PREFIX ) && CollectionUtils . isListSetMap ( SignatureUtils . stripSignature ( signature ) ) ) { stack . resetForMethodEntry... | overrides the visitor to reset the stack for the new method then checks if the immutability field is set to immutable and if so reports it |
3,208 | public void sawOpcode ( int seen ) { ImmutabilityType seenImmutable = null ; try { stack . precomputation ( this ) ; switch ( seen ) { case Const . INVOKESTATIC : { String className = getClassConstantOperand ( ) ; String methodName = getNameConstantOperand ( ) ; if ( IMMUTABLE_PRODUCING_METHODS . contains ( className +... | overrides the visitor to look for calls to static methods that are known to return immutable collections It records those variables and documents if what the method returns is one of those objects . |
3,209 | private boolean isJavaXExternal ( String className ) { if ( ! className . startsWith ( "javax/" ) ) { return false ; } if ( className . startsWith ( "javax/xml/" ) ) { return true ; } int lastSlashPos = className . lastIndexOf ( '/' ) ; String packageName = className . substring ( 0 , lastSlashPos ) ; ZipEntry ze = jdk... | checks to see if this class is a javax . xxxx . Foo class if so looks to see if the package is at least in the jdk if a whole new package comes into javax in rt . jar this will be missed . Need a better solution here . |
3,210 | 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 |
3,211 | 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 |
3,212 | 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 |
3,213 | 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 |
3,214 | 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 . |
3,215 | 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 . |
3,216 | 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 |
3,217 | 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 ... |
3,218 | 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 . |
3,219 | @ 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 |
3,220 | @ 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 |
3,221 | 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 . |
3,222 | 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 |
3,223 | 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 . |
3,224 | 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 . |
3,225 | 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 . |
3,226 | 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 |
3,227 | 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 . |
3,228 | 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 . |
3,229 | 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 |
3,230 | 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 |
3,231 | 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 . |
3,232 | 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 |
3,233 | 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 |
3,234 | public void visitMethod ( Method obj ) { methodName = obj . getName ( ) ; methodSig = obj . getSignature ( ) ; } | overrides the visitor collect method info |
3,235 | 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 . |
3,236 | 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 |
3,237 | 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 |
3,238 | 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 . |
3,239 | 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 |
3,240 | 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 |
3,241 | 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 |
3,242 | 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 |
3,243 | 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 |
3,244 | 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 |
3,245 | 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 . |
3,246 | 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 |
3,247 | 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 |
3,248 | public void visitClassContext ( ClassContext clsContext ) { try { stack = new OpcodeStack ( ) ; super . visitClassContext ( clsContext ) ; } finally { stack = null ; } } | overrides the visitor to setup the opcode stack |
3,249 | 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 |
3,250 | 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 . |
3,251 | 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 |
3,252 | 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 |
3,253 | 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 |
3,254 | 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 |
3,255 | 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 |
3,256 | 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 . |
3,257 | 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 |
3,258 | 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 . |
3,259 | 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 |
3,260 | 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 |
3,261 | 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 . |
3,262 | 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 |
3,263 | 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 |
3,264 | 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 |
3,265 | 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 |
3,266 | 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 |
3,267 | 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 |
3,268 | 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 |
3,269 | 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 |
3,270 | 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 . |
3,271 | 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 . |
3,272 | 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 |
3,273 | 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 . |
3,274 | 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 |
3,275 | 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 . |
3,276 | 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 |
3,277 | 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 |
3,278 | 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 |
3,279 | 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 |
3,280 | 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 . |
3,281 | 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 . |
3,282 | 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 |
3,283 | 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 |
3,284 | 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 . |
3,285 | 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 |
3,286 | public void visitMethod ( final Method obj ) { methodName = obj . getName ( ) ; methodIsStatic = obj . isStatic ( ) ; } | overrides the visitor to check whether the method is static |
3,287 | @ 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 |
3,288 | 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 . |
3,289 | 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 |
3,290 | 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 |
3,291 | 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 |
3,292 | 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 |
3,293 | @ 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 |
3,294 | 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 |
3,295 | 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 |
3,296 | 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 |
3,297 | 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 . |
3,298 | 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 |
3,299 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.