idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
3,100 | public void visitClassContext ( ClassContext classContext ) { JavaClass cls = classContext . getJavaClass ( ) ; if ( cls . isClass ( ) && ( cls . getMajor ( ) >= JDK15_MAJOR ) ) { Map < String , Set < String > > methodInfo = new HashMap < > ( ) ; populateMethodInfo ( cls , methodInfo ) ; Method [ ] methods = cls . getM... | overrides the visitor to look for confusing signatures |
3,101 | private static boolean confusingSignatures ( String sig1 , String sig2 ) { if ( sig1 . equals ( sig2 ) ) { return false ; } List < String > type1 = SignatureUtils . getParameterSignatures ( sig1 ) ; List < String > type2 = SignatureUtils . getParameterSignatures ( sig2 ) ; if ( type1 . size ( ) != type2 . size ( ) ) { ... | returns if one signature is a Character and the other is a primitive |
3,102 | private void populateMethodInfo ( JavaClass cls , Map < String , Set < String > > methodInfo ) { try { if ( Values . DOTTED_JAVA_LANG_OBJECT . equals ( cls . getClassName ( ) ) ) { return ; } Method [ ] methods = cls . getMethods ( ) ; for ( Method m : methods ) { String sig = m . getSignature ( ) ; if ( isPossiblyConf... | fills out a set of method details for possibly confusing method signatures |
3,103 | private static boolean isPossiblyConfusingSignature ( String sig ) { List < String > types = SignatureUtils . getParameterSignatures ( sig ) ; for ( String typeSig : types ) { if ( primitiveSigs . contains ( typeSig ) || SignatureUtils . classToSignature ( Values . SLASHED_JAVA_LANG_CHARACTER ) . equals ( typeSig ) ) {... | returns whether a method signature has either a Character or primitive |
3,104 | public void visitCode ( Code obj ) { stack . resetForMethodEntry ( this ) ; toStringRegisters . clear ( ) ; super . visitCode ( obj ) ; } | overrides the visitor to resets the stack for this method . |
3,105 | public void sawOpcode ( int seen ) { String methodPackage = null ; try { stack . precomputation ( this ) ; if ( seen == Const . INVOKEVIRTUAL ) { methodPackage = processInvokeVirtual ( ) ; } else if ( OpcodeUtils . isAStore ( seen ) ) { if ( stack . getStackDepth ( ) > 0 ) { OpcodeStack . Item item = stack . getStackIt... | overrides the visitor to look for suspicious operations on toString |
3,106 | public void visitCode ( Code obj ) { try { Method method = getMethod ( ) ; if ( method . isSynthetic ( ) ) { return ; } isBooleanMethod = Type . BOOLEAN . equals ( method . getReturnType ( ) ) ; if ( isBooleanMethod || prescreen ( method ) ) { catchHandlerPCs = collectExceptions ( obj . getExceptionTable ( ) ) ; if ( !... | overrides the visitor to look for methods that catch checked exceptions and rethrow runtime exceptions |
3,107 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; int pc = getPC ( ) ; CodeException ex = catchHandlerPCs . get ( Integer . valueOf ( pc ) ) ; if ( ex != null ) { int endPC ; if ( ( seen == Const . GOTO ) || ( seen == Const . GOTO_W ) ) { endPC = this . getBranchTarget ( ) ; } else { endPC = ... | overrides the visitor to find catch blocks that throw runtime exceptions |
3,108 | private static void removeFinishedCatchBlocks ( Iterable < CatchInfo > infos , int pc ) { Iterator < CatchInfo > it = infos . iterator ( ) ; while ( it . hasNext ( ) ) { if ( it . next ( ) . getFinish ( ) < pc ) { it . remove ( ) ; } } } | remove catchinfo blocks from the map where the handler end is before the current pc |
3,109 | private void updateEndPCsOnCatchRegScope ( List < CatchInfo > infos , int pc , int seen ) { if ( lvt != null ) { for ( CatchInfo ci : infos ) { if ( ( ci . getStart ( ) == pc ) && OpcodeUtils . isAStore ( seen ) ) { int exReg = RegisterUtils . getAStoreReg ( this , seen ) ; LocalVariable lv = lvt . getLocalVariable ( e... | reduces the end pc based on the optional LocalVariableTable s exception register scope |
3,110 | private static Set < String > findPossibleCatchSignatures ( List < CatchInfo > infos , int pc ) { Set < String > catchTypes = new HashSet < > ( 6 ) ; ListIterator < CatchInfo > it = infos . listIterator ( infos . size ( ) ) ; while ( it . hasPrevious ( ) ) { CatchInfo ci = it . previous ( ) ; if ( ( pc >= ci . getStart... | returns an array of catch types that the current pc is in |
3,111 | private Map < String , Set < String > > getConstrainingInfo ( JavaClass cls , Method m ) throws ClassNotFoundException { String methodName = m . getName ( ) ; String methodSig = m . getSignature ( ) ; { JavaClass [ ] infClasses = cls . getInterfaces ( ) ; for ( JavaClass infCls : infClasses ) { Method infMethod = findM... | finds the super class or interface that constrains the types of exceptions that can be thrown from the given method |
3,112 | private static Method findMethod ( JavaClass cls , String methodName , String methodSig ) { Method [ ] methods = cls . getMethods ( ) ; for ( Method method : methods ) { if ( method . getName ( ) . equals ( methodName ) && method . getSignature ( ) . equals ( methodSig ) ) { return method ; } } return null ; } | finds a method that matches the name and signature in the given class |
3,113 | private Map < String , Set < String > > buildConstrainingInfo ( JavaClass cls , Method m ) throws ClassNotFoundException { Map < String , Set < String > > constraintInfo = new HashMap < > ( ) ; Set < String > exs = new HashSet < > ( ) ; ExceptionTable et = m . getExceptionTable ( ) ; if ( et != null ) { int [ ] indexTa... | returns exception names describing what exceptions are allowed to be thrown |
3,114 | public void visitCode ( Code obj ) { try { Method m = getMethod ( ) ; Type retType = m . getReturnType ( ) ; if ( "Ljava/lang/Boolean;" . equals ( retType . getSignature ( ) ) ) { stack . resetForMethodEntry ( this ) ; super . visitCode ( obj ) ; } } catch ( StopOpcodeParsingException e ) { } } | implements the visitor to filter out methods that don t return Boolean |
3,115 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( ( seen == Const . ARETURN ) && ( stack . getStackDepth ( ) > 0 ) ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; if ( item . isNull ( ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . TBP_TRISTATE_BOOLEAN_PATTE... | implements the visitor to look for null returns |
3,116 | public void visitClassContext ( ClassContext clsContext ) { try { if ( ( collectionCls == null ) || ( setCls == null ) || ( mapCls == null ) ) { return ; } stack = new OpcodeStack ( ) ; super . visitClassContext ( clsContext ) ; } finally { stack = null ; } } | implement the visitor to set up the opcode stack and make sure that collection set and map classes could be loaded . |
3,117 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( ( seen == Const . INVOKEVIRTUAL ) || ( seen == Const . INVOKEINTERFACE ) ) { String clsName = getClassConstantOperand ( ) ; String methodName = getNameConstantOperand ( ) ; String signature = getSigConstantOperand ( ) ; if ( "add" . equal... | implements the visitor look for adds to sets or puts to maps where the element to be added is a collection . |
3,118 | private boolean lookupSwitchOnString ( ) { if ( stack . getStackDepth ( ) > 1 ) { OpcodeStack . Item item = stack . getStackItem ( 1 ) ; String stringRef = ( String ) item . getUserValue ( ) ; if ( stringRef == null ) { return false ; } if ( ! lookupSwitches . isEmpty ( ) ) { LookupDetails details = lookupSwitches . ge... | looks to see if the string used in a equals or compareTo is the same as that of a switch statement s switch on string . |
3,119 | public void visitMethod ( Method obj ) { stack . resetForMethodEntry ( this ) ; jdbcLocals . clear ( ) ; int [ ] parmRegs = RegisterUtils . getParameterRegisters ( obj ) ; Type [ ] argTypes = obj . getArgumentTypes ( ) ; for ( int t = 0 ; t < argTypes . length ; t ++ ) { String sig = argTypes [ t ] . getSignature ( ) ;... | implement the visitor to reset the opcode stack and set of locals that are jdbc objects |
3,120 | private static boolean fieldHasRuntimeVisibleAnnotation ( Field f ) { AnnotationEntry [ ] annotations = f . getAnnotationEntries ( ) ; if ( annotations != null ) { for ( AnnotationEntry annotation : annotations ) { if ( annotation . isRuntimeVisible ( ) ) { return true ; } } } return false ; } | looks to see the field has a runtime visible annotation if it does it might be autowired or some other mechanism attached that makes them less interesting for a toString call . |
3,121 | private void checkIDEGeneratedParmNames ( JavaClass cls ) { for ( Method m : cls . getMethods ( ) ) { if ( isIDEGeneratedMethodWithCode ( m ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES . name ( ) , NORMAL_PRIORITY ) . addClass ( cls ) . addMethod ( ... | looks for methods that have it s parameters all follow the form arg0 arg1 arg2 or parm0 parm1 parm2 etc where the method actually has code in it |
3,122 | public void visitClassContext ( ClassContext classContext ) { try { ifStatements = new HashSet < > ( ) ; super . visitClassContext ( classContext ) ; } finally { ifStatements = null ; } } | implements the visitor to allocate and clear the ifStatements set |
3,123 | public void visitClassContext ( final ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; if ( ! cls . isFinal ( ) ) { stack = new OpcodeStack ( ) ; methodToCalledMethods = new HashMap < > ( ) ; super . visitClassContext ( classContext ) ; if ( ! methodToCalledMethods . isEmpty ( ) ) {... | implements the visitor to set up the stack and methodToCalledmethods map reports calls to public non final methods from methods called from constructors . |
3,124 | public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; changedAttributes = new HashMap < > ( ) ; savedAttributes = new HashMap < > ( ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; changedAttributes = null ; savedAttributes = null ; } } | implements the visitor to setup the opcode stack and attribute maps |
3,125 | public void visitCode ( Code obj ) { stack . resetForMethodEntry ( this ) ; changedAttributes . clear ( ) ; savedAttributes . clear ( ) ; super . visitCode ( obj ) ; for ( Integer pc : changedAttributes . values ( ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPO... | implements the visitor to report on attributes that have changed without a setAttribute being called on them |
3,126 | public void visitMethod ( final Method obj ) { methodName = obj . getName ( ) ; if ( Values . STATIC_INITIALIZER . equals ( methodName ) || Values . CONSTRUCTOR . equals ( methodName ) ) { return ; } List < String > parms = SignatureUtils . getParameterSignatures ( obj . getSignature ( ) ) ; if ( ! parms . isEmpty ( ) ... | overrides the visitor capture source lines for the method |
3,127 | private String [ ] getSourceLines ( Method obj ) { if ( srcInited ) { return sourceLines ; } try { srcLineAnnotation = SourceLineAnnotation . forEntireMethod ( getClassContext ( ) . getJavaClass ( ) , obj ) ; if ( srcLineAnnotation != null ) { SourceFinder sourceFinder = AnalysisContext . currentAnalysisContext ( ) . g... | reads the sourcefile based on the source line annotation for the method |
3,128 | public void visitCode ( final Code obj ) { if ( sourceLines == null ) { return ; } if ( isAbstract ) { return ; } if ( Values . STATIC_INITIALIZER . equals ( methodName ) || Values . CONSTRUCTOR . equals ( methodName ) ) { return ; } int methodStart = srcLineAnnotation . getStartLine ( ) - 2 ; int methodLine = methodSt... | overrides the visitor to find the source lines for the method header to find non final parameters |
3,129 | public void sawOpcode ( final int seen ) { if ( OpcodeUtils . isAStore ( seen ) ) { changedParms . set ( RegisterUtils . getAStoreReg ( this , seen ) ) ; } } | overrides the visitor to find local variable reference stores to store them as changed |
3,130 | private static String getRegisterName ( final Code obj , final int reg ) { LocalVariableTable lvt = obj . getLocalVariableTable ( ) ; if ( lvt != null ) { LocalVariable lv = lvt . getLocalVariable ( reg , 0 ) ; if ( lv != null ) { return lv . getName ( ) ; } } return String . valueOf ( reg ) ; } | returns the variable name of the specified register slot |
3,131 | public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; registerConstants = new HashMap < > ( ) ; overloadedMethods = collectOverloadedMethods ( classContext . getJavaClass ( ) ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; registerConstants = null ... | implements the visitor to collect all methods that are overloads . These methods should be ignored as you may differentiate Const based on parameter type or value . |
3,132 | public void visitCode ( Code obj ) { Method m = getMethod ( ) ; if ( overloadedMethods . contains ( m ) ) { return ; } int aFlags = m . getAccessFlags ( ) ; if ( ( ( ( aFlags & Const . ACC_PRIVATE ) != 0 ) || ( ( aFlags & Const . ACC_STATIC ) != 0 ) ) && ( ( aFlags & Const . ACC_SYNTHETIC ) == 0 ) && ( ! m . getSignatu... | implements the visitor to reset the stack and proceed for private methods |
3,133 | public void visitMethod ( Method obj ) { firstLocalRegister = SignatureUtils . getFirstRegisterSlot ( obj ) ; super . visitMethod ( obj ) ; } | overrides the visitor to see what how many register slots are taken by parameters . |
3,134 | public void sawOpcode ( int seen ) { if ( seen == Const . PUTFIELD ) { OpcodeStack stack = getStack ( ) ; if ( stack . getStackDepth ( ) > 0 ) { int reg = stack . getStackItem ( 0 ) . getRegisterNumber ( ) ; if ( ( reg >= 0 ) && ( reg < firstLocalRegister ) ) { clearSpecialField ( getNameConstantOperand ( ) ) ; } } } s... | overrides the visitor to look for PUTFIELDS of collections |
3,135 | protected boolean doesStaticFactoryReturnNeedToBeWatched ( String clsName , String methodName , String signature ) { return collectionFactoryMethods . contains ( new FQMethod ( clsName , methodName , signature ) ) ; } | implements the MissingMethodsDetector to determine whether this factory - like method returns a collection |
3,136 | public void visitClassContext ( ClassContext classContext ) { JavaClass cls = classContext . getJavaClass ( ) ; cls . accept ( this ) ; } | implements the visitor to accept the class for visiting |
3,137 | public void visitMethod ( Method obj ) { Attribute [ ] attributes = obj . getAttributes ( ) ; for ( Attribute a : attributes ) { if ( "Signature" . equals ( a . getName ( ) ) ) { TemplateSignature ts = parseSignatureAttribute ( ( Signature ) a ) ; if ( ts != null ) { for ( TemplateItem templateParm : ts . templateParam... | implements the visitor to find methods that declare template parameters that are not bound to any parameter . |
3,138 | private boolean isTemplateParent ( String templateType , TemplateItem ... items ) { for ( TemplateItem item : items ) { if ( templateType . equals ( item . templateExtension ) ) { return true ; } } return false ; } | looks to see if this templateType is a parent of another template type |
3,139 | private static TemplateSignature parseSignatureAttribute ( Signature signatureAttribute ) { Matcher m = TEMPLATED_SIGNATURE . matcher ( signatureAttribute . getSignature ( ) ) ; if ( ! m . matches ( ) ) { return null ; } TemplateSignature ts = new TemplateSignature ( ) ; ts . signature = m . group ( 2 ) ; m = TEMPLATE ... | builds a template signature object based on the signature attribute of the method |
3,140 | public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; mapBugs = new ArrayList < > ( ) ; setBugs = new ArrayList < > ( ) ; hasMapComparator = false ; hasSetComparator = false ; super . visitClassContext ( classContext ) ; if ( ! hasMapComparator ) { for ( BugInstance bi : mapB... | implement the visitor to report bugs if no Tree comparators were found |
3,141 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( seen == Const . INVOKEINTERFACE ) { processInvokeInterface ( ) ; } else if ( seen == Const . INVOKESPECIAL ) { processInvokeSpecial ( ) ; } } finally { stack . sawOpcode ( this , seen ) ; } } | implements the visitor to find accesses to maps sets and lists using arrays |
3,142 | public void visitMethod ( final Method obj ) { if ( obj . isSynthetic ( ) ) { return ; } ExceptionTable et = obj . getExceptionTable ( ) ; if ( et != null ) { String [ ] exNames = et . getExceptionNames ( ) ; Set < String > methodRTExceptions = new HashSet < > ( 6 ) ; int priority = LOW_PRIORITY ; boolean foundRuntime ... | overrides the visitor to find declared runtime exceptions |
3,143 | public static void post ( OpcodeStack stack , int opcode ) { if ( ! sawGOTO || ( opcode == Const . GOTO ) || ( opcode == Const . GOTO_W ) ) { return ; } int depth = stack . getStackDepth ( ) ; for ( int i = 0 ; i < depth && i < userValues . size ( ) ; i ++ ) { OpcodeStack . Item item = stack . getStackItem ( i ) ; if (... | called after the execution of the parent OpcodeStack . sawOpcode to restore the user values after the GOTO or GOTO_W s mergeJumps were processed |
3,144 | public void visitCode ( Code obj ) { try { userValues = new HashMap < > ( ) ; super . visitCode ( obj ) ; } finally { userValues = null ; } } | implements the visitor to reset the uservalues |
3,145 | public void visitClassContext ( ClassContext context ) { try { JavaClass cls = context . getJavaClass ( ) ; if ( ! cls . isEnum ( ) && ( cls . getMajor ( ) >= Const . MAJOR_1_5 ) ) { Method [ ] methods = cls . getMethods ( ) ; for ( Method m : methods ) { if ( Values . CONSTRUCTOR . equals ( m . getName ( ) ) && ! m . ... | implements the visitor to look for classes compiled with 1 . 5 or better that have all constructors that are private |
3,146 | public void visitField ( Field obj ) { if ( obj . isStatic ( ) && obj . isPublic ( ) && obj . isFinal ( ) ) { JavaClass cls = getClassContext ( ) . getJavaClass ( ) ; if ( ! obj . isEnum ( ) ) { String fieldClass = obj . getSignature ( ) ; if ( fieldClass . startsWith ( Values . SIG_QUALIFIED_CLASS_PREFIX ) ) { fieldCl... | implements the visitor to look for fields that are public static final and are the same type as the owning class . it collects these object names for later |
3,147 | public void visitCode ( Code obj ) { if ( Values . STATIC_INITIALIZER . equals ( getMethod ( ) . getName ( ) ) ) { state = State . SAW_NOTHING ; super . visitCode ( obj ) ; } } | implements the visitor to look for static initializers to find enum generation |
3,148 | public void sawOpcode ( int seen ) { if ( state == State . SAW_NOTHING ) { if ( seen == Const . INVOKESPECIAL ) { state = State . SAW_INVOKESPECIAL ; } } else if ( state == State . SAW_INVOKESPECIAL ) { handleInvokeSpecialState ( seen ) ; } } | implements the visitor to find allocations of TypesafeEnum Const |
3,149 | public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; constrainingMethods = buildConstrainingMethods ( cls ) ; AnnotationEntry [ ] annotations = cls . getAnnotationEntries ( ) ; classHasAnnotation = ! CollectionUtils . isEmpty ( annotations ) ; stack = new... | implements the visitor to collect statistics on this class |
3,150 | private boolean isFirstUse ( int reg ) { LocalVariableTable lvt = getMethod ( ) . getLocalVariableTable ( ) ; if ( lvt == null ) { return true ; } LocalVariable lv = lvt . getLocalVariable ( reg , getPC ( ) ) ; return lv == null ; } | looks to see if this register has already in scope or whether is a new assignment . return true if it s a new assignment . If you can t tell return true anyway . might want to change . |
3,151 | public void visitClassContext ( ClassContext clsContext ) { try { JavaClass cls = clsContext . getJavaClass ( ) ; String superName = cls . getSuperclassName ( ) ; if ( ! Values . DOTTED_JAVA_LANG_OBJECT . equals ( superName ) ) { this . classContext = clsContext ; superclassCode = new HashMap < > ( ) ; JavaClass superC... | overrides the visitor to accept classes derived from non java . lang . Object classes . |
3,152 | public void visitCode ( Code obj ) { try { Method m = getMethod ( ) ; if ( ( ! m . isPublic ( ) && ! m . isProtected ( ) ) || m . isAbstract ( ) || m . isSynthetic ( ) ) { return ; } CodeInfo superCode = superclassCode . remove ( curMethodInfo ) ; if ( superCode != null ) { if ( sameAccess ( getMethod ( ) . getAccessFl... | overrides the visitor to find code blocks of methods that are the same as its parents |
3,153 | public void sawOpcode ( int seen ) { if ( ! sawAload0 ) { if ( seen == Const . ALOAD_0 ) { sawAload0 = true ; } else { throw new StopOpcodeParsingException ( ) ; } } else if ( nextParmIndex < parmTypes . length ) { if ( isExpectedParmInstruction ( seen , nextParmOffset , parmTypes [ nextParmIndex ] ) ) { nextParmOffset... | overrides the visitor to look for an exact call to the parent class s method using this methods parm . |
3,154 | private static boolean sameAccess ( int parentAccess , int childAccess ) { return ( ( parentAccess & ( Const . ACC_PUBLIC | Const . ACC_PROTECTED ) ) == ( childAccess & ( Const . ACC_PUBLIC | Const . ACC_PROTECTED ) ) ) ; } | determines if two access flags contain the same access modifiers |
3,155 | public void visitMethod ( Method obj ) { Code c = obj . getCode ( ) ; if ( c != null ) { byte [ ] opcodes = c . getCode ( ) ; if ( opcodes != null ) { trPCPos = opcodes . length - 1 ; if ( ! obj . getSignature ( ) . endsWith ( Values . SIG_VOID ) ) { trPCPos -= 1 ; } trPCPos -= TAILRECURSIONFUDGE ; possibleTailRecursio... | implements the visitor to figure the pc where the method call must occur depending on whether the method returns a value or not . |
3,156 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( seen == Const . INVOKEVIRTUAL ) { checkForTailRecursion ( ) ; } } finally { stack . sawOpcode ( this , seen ) ; } } | implements the visitor to find methods that employ tail recursion |
3,157 | public void sawOpcode ( int seen ) { if ( seen == Const . INVOKEVIRTUAL ) { String className = getClassConstantOperand ( ) ; String methodName = getNameConstantOperand ( ) ; String methodSig = getSigConstantOperand ( ) ; FQMethod methodInfo = new FQMethod ( className , methodName , methodSig ) ; if ( oldMethods . conta... | implements the visitor to look for method calls that are one of the old pre - collections1 . 2 set of methods |
3,158 | public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; nodeCreations = new HashMap < > ( ) ; nodeStores = new HashMap < > ( ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; nodeCreations = null ; nodeStores = null ; } } | implements the visitor to create and clear the stack node creations and store maps |
3,159 | public void visitCode ( Code obj ) { stack . resetForMethodEntry ( this ) ; nodeCreations . clear ( ) ; nodeStores . clear ( ) ; super . visitCode ( obj ) ; BitSet reportedPCs = new BitSet ( ) ; for ( Integer pc : nodeCreations . values ( ) ) { if ( ! reportedPCs . get ( pc . intValue ( ) ) ) { bugReporter . reportBug ... | implements the visitor to clear the opcode stack for the next code |
3,160 | private Integer findDOMNodeCreationPoint ( int index ) { if ( stack . getStackDepth ( ) <= index ) { return null ; } return nodeCreations . remove ( stack . getStackItem ( index ) ) ; } | returns the pc where this DOM Node was created or null if this isn t a DOM node that was created |
3,161 | public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; if ( cls . isAbstract ( ) ) { interfaceMethods = collectInterfaceMethods ( cls ) ; super . visitClassContext ( classContext ) ; } } catch ( ClassNotFoundException cnfe ) { bugReporter . reportMissingCla... | overrides the visitor to check for abstract classes . |
3,162 | public void visitCode ( Code obj ) { if ( Values . CONSTRUCTOR . equals ( methodName ) || Values . STATIC_INITIALIZER . equals ( methodName ) ) { return ; } Method m = getMethod ( ) ; if ( m . isSynthetic ( ) ) { return ; } if ( ! interfaceMethods . contains ( new QMethod ( methodName , m . getSignature ( ) ) ) ) { sup... | overrides the visitor to filter out constructors . |
3,163 | public void sawOpcode ( int seen ) { try { switch ( state ) { case SAW_NOTHING : if ( seen == Const . RETURN ) { bugReporter . reportBug ( new BugInstance ( this , BugType . ACEM_ABSTRACT_CLASS_EMPTY_METHODS . name ( ) , NORMAL_PRIORITY ) . addClass ( this ) . addMethod ( this ) . addSourceLine ( this ) ) ; state = Sta... | overrides the visitor to look for empty methods or simple exception throwers . |
3,164 | private boolean prescreen ( Method method ) { BitSet bytecodeSet = getClassContext ( ) . getBytecodeSet ( method ) ; return ( bytecodeSet != null ) && bytecodeSet . intersects ( arrayLoadOps ) ; } | looks for methods that contain array load opcodes |
3,165 | private static boolean similarArrayInstructions ( int load , int store ) { return ( ( load == Const . AALOAD ) && ( store == Const . AASTORE ) ) || ( ( load == Const . IALOAD ) && ( store == Const . IASTORE ) ) || ( ( load == Const . DALOAD ) && ( store == Const . DASTORE ) ) || ( ( load == Const . LALOAD ) && ( store ... | looks to see if a load and store operation are working on the same type of array |
3,166 | public void visitCode ( Code obj ) { try { possibleParmRegs . clear ( ) ; Method m = getMethod ( ) ; String methodSignature = m . getSignature ( ) ; String retSignature = SignatureUtils . getReturnSignature ( methodSignature ) ; JavaClass returnClass = null ; int [ ] parmRegs = null ; if ( retSignature . startsWith ( V... | implements the visitor to look for any non - immutable typed parameters are assignable to the return type . If found the method is parsed . |
3,167 | public static boolean isListSetMap ( String clsName ) throws ClassNotFoundException { JavaClass cls = Repository . lookupClass ( clsName ) ; return ( cls . implementationOf ( LIST_CLASS ) || cls . implementationOf ( SET_CLASS ) || cls . implementationOf ( MAP_CLASS ) ) ; } | determines if the current class name is derived from List Set or Map |
3,168 | private boolean prescreen ( Method method ) { BitSet bytecodeSet = getClassContext ( ) . getBytecodeSet ( method ) ; return ( bytecodeSet != null ) && ( bytecodeSet . get ( Const . CHECKCAST ) ) ; } | looks for methods that contain a checkcast instruction |
3,169 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; if ( ( seen == Const . CHECKCAST ) && ( stack . getStackDepth ( ) > 0 ) ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; if ( item . getRegisterNumber ( ) == 1 ) { String thisCls = getClassName ( ) ; String equalsCls = getClassConsta... | implements the visitor to look for checkcasts of the parameter to other types and enter instances in a map for further processing in doReport . |
3,170 | public void report ( ) { for ( Map . Entry < String , Map < String , BugInstance > > thisEntry : possibleBugs . entrySet ( ) ) { Map < String , BugInstance > equalsClassesMap = thisEntry . getValue ( ) ; for ( Map . Entry < String , BugInstance > equalsEntry : equalsClassesMap . entrySet ( ) ) { String equalsCls = equa... | reports all the collected issues from the parse of this class |
3,171 | public void visitClassContext ( ClassContext classContext ) { try { ignoreRegs = new BitSet ( ) ; tryBlocks = new BitSet ( ) ; catchHandlers = new BitSet ( ) ; switchTargets = new BitSet ( ) ; monitorSyncPCs = new ArrayList < > ( 5 ) ; stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } finally... | implements the visitor to create and the clear the register to location map |
3,172 | public void visitCode ( Code obj ) { try { ignoreRegs . clear ( ) ; Method method = getMethod ( ) ; if ( ! method . isStatic ( ) ) { ignoreRegs . set ( 0 ) ; } int [ ] parmRegs = RegisterUtils . getParameterRegisters ( method ) ; for ( int parm : parmRegs ) { ignoreRegs . set ( parm ) ; } rootScopeBlock = new ScopeBloc... | implements the visitor to reset the register to location map |
3,173 | public void sawOpcode ( int seen ) { UserObject uo = null ; try { stack . precomputation ( this ) ; int pc = getPC ( ) ; if ( tryBlocks . get ( pc ) ) { ScopeBlock sb = new ScopeBlock ( pc , findCatchHandlerFor ( pc ) ) ; sb . setTry ( ) ; rootScopeBlock . addChild ( sb ) ; } if ( OpcodeUtils . isStore ( seen ) ) { saw... | implements the visitor to look for variables assigned below the scope in which they are used . |
3,174 | private void sawStore ( int seen , int pc ) { int reg = RegisterUtils . getStoreReg ( this , seen ) ; if ( catchHandlers . get ( pc ) ) { ignoreRegs . set ( reg ) ; ScopeBlock catchSB = findScopeBlock ( rootScopeBlock , pc + 1 ) ; if ( ( catchSB != null ) && ( catchSB . getStart ( ) < pc ) ) { ScopeBlock sb = new Scope... | processes a register store by updating the appropriate scope block to mark this register as being stored in the block |
3,175 | private void sawIINC ( int pc ) { int reg = getRegisterOperand ( ) ; if ( ! ignoreRegs . get ( reg ) ) { ScopeBlock sb = findScopeBlock ( rootScopeBlock , pc ) ; if ( sb != null ) { sb . addLoad ( reg , pc ) ; } else { ignoreRegs . set ( reg ) ; } } if ( catchHandlers . get ( pc ) ) { ignoreRegs . set ( reg ) ; } else ... | processes a register IINC by updating the appropriate scope block to mark this register as being stored in the block |
3,176 | private void sawLoad ( int seen , int pc ) { int reg = RegisterUtils . getLoadReg ( this , seen ) ; if ( ! ignoreRegs . get ( reg ) ) { ScopeBlock sb = findScopeBlock ( rootScopeBlock , pc ) ; if ( sb != null ) { sb . addLoad ( reg , pc ) ; } else { ignoreRegs . set ( reg ) ; } } } | processes a register store by updating the appropriate scope block to mark this register as being read in the block |
3,177 | private void sawBranch ( int seen , int pc ) { int target = getBranchTarget ( ) ; if ( target > pc ) { if ( ( seen == Const . GOTO ) || ( seen == Const . GOTO_W ) ) { int nextPC = getNextPC ( ) ; if ( ! switchTargets . get ( nextPC ) ) { ScopeBlock sb = findScopeBlockWithTarget ( rootScopeBlock , pc , nextPC ) ; if ( s... | creates a scope block to describe this branch location . |
3,178 | private void sawSwitch ( int pc ) { int [ ] offsets = getSwitchOffsets ( ) ; List < Integer > targets = new ArrayList < > ( offsets . length ) ; for ( int offset : offsets ) { targets . add ( Integer . valueOf ( offset + pc ) ) ; } Integer defOffset = Integer . valueOf ( getDefaultSwitchOffset ( ) + pc ) ; if ( ! targe... | creates a new scope block for each case statement |
3,179 | private UserObject sawStaticCall ( ) { if ( getSigConstantOperand ( ) . endsWith ( Values . SIG_VOID ) ) { return null ; } return new UserObject ( isRiskyMethodCall ( ) ) ; } | processes a static call or initializer by checking to see if the call is risky and returning a OpcodeStack item user value saying so . |
3,180 | private void sawMonitorEnter ( int pc ) { monitorSyncPCs . add ( Integer . valueOf ( pc ) ) ; ScopeBlock sb = new ScopeBlock ( pc , Integer . MAX_VALUE ) ; sb . setSync ( ) ; rootScopeBlock . addChild ( sb ) ; } | processes a monitor enter call to create a scope block |
3,181 | private void sawMonitorExit ( int pc ) { if ( ! monitorSyncPCs . isEmpty ( ) ) { ScopeBlock sb = findSynchronizedScopeBlock ( rootScopeBlock , monitorSyncPCs . get ( 0 ) . intValue ( ) ) ; if ( sb != null ) { sb . setFinish ( pc ) ; } monitorSyncPCs . remove ( monitorSyncPCs . size ( ) - 1 ) ; } } | processes a monitor exit to set the end of the already created scope block |
3,182 | private Comparable < ? > getCallingObject ( ) { String sig = getSigConstantOperand ( ) ; if ( Values . SIG_VOID . equals ( SignatureUtils . getReturnSignature ( sig ) ) ) { return null ; } int numParameters = SignatureUtils . getNumParameters ( sig ) ; if ( stack . getStackDepth ( ) <= numParameters ) { return null ; }... | returns either a register number of a field reference of the object that a method is being called on or null if it can t be determined . |
3,183 | private ScopeBlock findScopeBlock ( ScopeBlock sb , int pc ) { if ( ( pc <= sb . getStart ( ) ) || ( pc >= sb . getFinish ( ) ) ) { return null ; } List < ScopeBlock > children = sb . getChildren ( ) ; if ( children != null ) { for ( ScopeBlock child : children ) { ScopeBlock foundSb = findScopeBlock ( child , pc ) ; i... | returns the scope block in which this register was assigned by traversing the scope block tree |
3,184 | private ScopeBlock findScopeBlockWithTarget ( ScopeBlock sb , int start , int target ) { ScopeBlock parentBlock = null ; int finishLocation = sb . getFinish ( ) ; if ( ( sb . getStart ( ) < start ) && ( finishLocation >= start ) && ( ( finishLocation <= target ) || ( sb . isGoto ( ) && ! sb . isLoop ( ) ) ) ) { parentB... | returns an existing scope block that has the same target as the one looked for |
3,185 | private ScopeBlock findPreviousSiblingScopeBlock ( ScopeBlock sb ) { ScopeBlock parent = sb . getParent ( ) ; if ( parent == null ) { return null ; } List < ScopeBlock > children = parent . getChildren ( ) ; if ( children == null ) { return null ; } ScopeBlock lastSibling = null ; for ( ScopeBlock sibling : children ) ... | looks for the ScopeBlock has the same parent as this given one but precedes it in the list . |
3,186 | private ScopeBlock findSynchronizedScopeBlock ( ScopeBlock sb , int monitorEnterPC ) { ScopeBlock monitorBlock = sb ; if ( sb . hasChildren ( ) ) { for ( ScopeBlock child : sb . getChildren ( ) ) { if ( child . isSync ( ) && ( child . getStart ( ) > monitorBlock . getStart ( ) ) ) { monitorBlock = child ; monitorBlock ... | finds the scope block that is the active synchronized block |
3,187 | private int findCatchHandlerFor ( int pc ) { CodeException [ ] exceptions = getMethod ( ) . getCode ( ) . getExceptionTable ( ) ; if ( exceptions != null ) { for ( CodeException ex : exceptions ) { if ( ex . getStartPC ( ) == pc ) { return ex . getHandlerPC ( ) ; } } } return - 1 ; } | returns the catch handler for a given try block |
3,188 | public void visitClassContext ( ClassContext classContext ) { if ( cloneableClass == null ) { return ; } try { JavaClass cls = classContext . getJavaClass ( ) ; if ( cls . implementationOf ( cloneableClass ) ) { stack = new OpcodeStack ( ) ; super . visitClassContext ( classContext ) ; } } catch ( ClassNotFoundExceptio... | override the visitor to look for classes that implement Cloneable |
3,189 | public void visitCode ( Code obj ) { Method m = getMethod ( ) ; if ( ! m . isStatic ( ) && "clone" . equals ( m . getName ( ) ) && SIG_VOID_TO_OBJECT . equals ( m . getSignature ( ) ) ) { super . visitCode ( obj ) ; } } | override the visitor to only continue for the clone method |
3,190 | public void sawOpcode ( int seen ) { boolean srcField = false ; try { stack . precomputation ( this ) ; switch ( seen ) { case Const . ALOAD_0 : srcField = true ; break ; case Const . DUP : if ( stack . getStackDepth ( ) > 0 ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; if ( item . getUserValue ( ) != null... | override the visitor to look for stores to member fields of the source object on a clone |
3,191 | public void visitClassContext ( ClassContext classContext ) { try { queryLocations = new ArrayList < > ( ) ; loops = new ArrayList < > ( ) ; super . visitClassContext ( classContext ) ; } finally { queryLocations = null ; loops = null ; } } | implements the visitor to create and clear the query locations and loops collections |
3,192 | public void visitCode ( Code obj ) { queryLocations . clear ( ) ; loops . clear ( ) ; super . visitCode ( obj ) ; for ( Integer qLoc : queryLocations ) { for ( LoopLocation lLoc : loops ) { if ( lLoc . isInLoop ( qLoc . intValue ( ) ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . SIL_SQL_IN_LOOP . na... | implements the visitor to clear the collections and report the query locations that are in loops |
3,193 | public void sawOpcode ( int seen ) { if ( seen == Const . INVOKEINTERFACE ) { String clsName = getClassConstantOperand ( ) ; String methodName = getNameConstantOperand ( ) ; if ( queryClasses . contains ( clsName ) && queryMethods . contains ( methodName ) ) { queryLocations . add ( Integer . valueOf ( getPC ( ) ) ) ; ... | implements the visitor to collect positions of queries and loops |
3,194 | public void visitCode ( Code obj ) { Method m = getMethod ( ) ; if ( prescreen ( m ) ) { stack . resetForMethodEntry ( this ) ; popStack . clear ( ) ; super . visitCode ( obj ) ; } } | implement the visitor to reset the stack |
3,195 | private void processMethodCall ( ) { int numParams = SignatureUtils . getNumParameters ( getSigConstantOperand ( ) ) ; int depth = stack . getStackDepth ( ) ; for ( int i = 0 ; i < numParams ; i ++ ) { if ( depth > i ) { OpcodeStack . Item item = stack . getStackItem ( i ) ; XField xf = item . getXField ( ) ; if ( xf !... | parses all the parameters of a called method and removes any of the parameters that are maps currently being looked at for this detector |
3,196 | public void visitCode ( Code obj ) { state = State . SAW_NOTHING ; lvt = obj . getLocalVariableTable ( ) ; if ( ( lvt != null ) && prescreen ( getMethod ( ) ) ) { super . visitCode ( obj ) ; } } | implements the visitor to set the state on entry of the code block to SAW_NOTHING and to see if there is a local variable table |
3,197 | public void sawOpcode ( int seen ) { switch ( state ) { case SAW_NOTHING : if ( seen == Const . CHECKCAST ) { castClass = getClassConstantOperand ( ) ; state = State . SAW_CHECKCAST ; } else if ( seen == Const . INVOKEINTERFACE ) { String clsName = getClassConstantOperand ( ) ; String methodName = getNameConstantOperan... | implements the visitor to look for a checkcast followed by a astore where the types of the objects are different . |
3,198 | public static void clearAssumptions ( Map < Integer , Integer > assumptionTill , int pc ) { Iterator < Integer > it = assumptionTill . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { if ( it . next ( ) . intValue ( ) <= pc ) { it . remove ( ) ; } } } | the map is keyed by register and value by when an assumption holds to a byte offset if we have passed when the assumption holds clear the item from the map |
3,199 | public void clearBranchTargets ( int pc ) { Iterator < Integer > it = branchTargets . iterator ( ) ; while ( it . hasNext ( ) ) { int target = it . next ( ) . intValue ( ) ; if ( target <= pc ) { it . remove ( ) ; } } } | remove branch targets that have been passed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.