idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
126,600 | public String getString ( String key ) throws MissingResourceException { ResourceBundle bundle = getBundle ( ) ; return bundle . getString ( key ) ; } | Retrieve a raw string from bundle . |
126,601 | public ResourceBundle getBundle ( ) throws MissingResourceException { if ( null == m_bundle ) { ClassLoader classLoader = m_classLoader ; if ( null == classLoader ) { classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; } if ( null != classLoader ) { m_bundle = ResourceBundle . getBundle ( m_baseName ... | Retrieve underlying ResourceBundle . If bundle has not been loaded it will be loaded by this method . Access is given in case other resources need to be extracted that this Manager does not provide simplified access to . |
126,602 | private String getPatternString ( String key ) throws MissingResourceException { ResourceBundle bundle = getBundle ( ) ; Object object = bundle . getObject ( key ) ; if ( object instanceof String ) { return ( String ) object ; } else if ( object instanceof String [ ] ) { String [ ] strings = ( String [ ] ) object ; ret... | Utility method to retrieve a string from ResourceBundle . If the key is a single string then that will be returned . If key refers to string array then a random string will be chosen . Other types cause an exception . |
126,603 | public static Store < InputStream > anonymousStore ( ) throws IOException { File temp = File . createTempFile ( "ops4j-store-anonymous-" , "" ) ; temp . delete ( ) ; temp . mkdir ( ) ; return new TemporaryStore ( temp , true ) ; } | If the store must be unique here is it . |
126,604 | @ SuppressWarnings ( "unchecked" ) private < T > Class < T > loadClassIfVisible ( String className , ClassLoader classLoader ) { try { Class < T > klass = ( Class < T > ) classLoader . loadClass ( className ) ; return klass ; } catch ( ClassNotFoundException e ) { return null ; } } | Loads a class with the given name from the given class loader . |
126,605 | public static InputStream prepareInputStream ( final URL url , final boolean acceptAnyCertificate ) throws IOException { final URLConnection conn = url . openConnection ( ) ; prepareForAuthentication ( conn ) ; prepareHttpHeaders ( conn ) ; if ( acceptAnyCertificate ) { prepareForSSL ( conn ) ; } return conn . getInput... | Prepare url for authentication and ssl if necessary and returns the input stream from the url . |
126,606 | public static void validateNotEmpty ( String stringToCheck , String argumentName ) throws NullArgumentException { validateNotEmpty ( stringToCheck , false , argumentName ) ; } | Validates that the string is not null and not an empty string without trimming the string . |
126,607 | public static void validateNotEmpty ( String stringToCheck , boolean trim , String argumentName ) throws NullArgumentException { validateNotNull ( stringToCheck , argumentName ) ; if ( stringToCheck . length ( ) == 0 || ( trim && stringToCheck . trim ( ) . length ( ) == 0 ) ) { throw new NullArgumentException ( argumen... | Validates that the string is not null and not an empty string . |
126,608 | public static void validateNotEmpty ( Properties propertiesToCheck , String argumentName ) throws NullArgumentException { validateNotNull ( propertiesToCheck , argumentName ) ; if ( propertiesToCheck . isEmpty ( ) ) { throw new NullArgumentException ( argumentName + IS_EMPTY ) ; } } | Validates that the Properties instance is not null and that it has entries . |
126,609 | public static void validateNotEmpty ( Object [ ] arrayToCheck , String argumentName ) throws NullArgumentException { validateNotNull ( arrayToCheck , argumentName ) ; if ( arrayToCheck . length == 0 ) { throw new NullArgumentException ( argumentName + IS_EMPTY ) ; } } | Validates that the array instance is not null and that it has entries . |
126,610 | public static void validateNotEmptyContent ( String [ ] arrayToCheck , String argumentName ) throws NullArgumentException { validateNotEmptyContent ( arrayToCheck , false , argumentName ) ; } | Validates that the string array instance is not null and that it has entries that are not null or empty eithout trimming the string . |
126,611 | public static void validateNotEmptyContent ( String [ ] arrayToCheck , boolean trim , String argumentName ) throws NullArgumentException { validateNotEmpty ( arrayToCheck , argumentName ) ; for ( int i = 0 ; i < arrayToCheck . length ; i ++ ) { validateNotEmpty ( arrayToCheck [ i ] , arrayToCheck [ i ] + "[" + i + "]" ... | Validates that the string array instance is not null and that it has entries that are not null or empty . |
126,612 | @ SuppressWarnings ( "unchecked" ) public < T > T get ( final String propertyName ) { return ( T ) m_properties . get ( propertyName ) ; } | Returns the property by name . |
126,613 | protected Map < String , ZipEntry > getEntries ( ZipFile zf ) { Enumeration < ? > e = zf . entries ( ) ; Map < String , ZipEntry > m = new HashMap < String , ZipEntry > ( ) ; while ( e . hasMoreElements ( ) ) { ZipEntry ze = ( ZipEntry ) e . nextElement ( ) ; m . put ( ze . getName ( ) , ze ) ; } return m ; } | Get all the entries in a ZIP file . |
126,614 | protected static void printHelp ( ) { System . out . println ( ) ; System . out . println ( "Usage: java " + ZipExploder . class . getName ( ) + " (-jar jarFilename... | -zip zipFilename...)... -dir destDir {-verbose}" ) ; System . out . println ( "Where:" ) ; System . out . println ( " jarFilename path to source jar,... | Print command help text . |
126,615 | public static void main ( final String [ ] args ) { if ( args . length == 0 ) { printHelp ( ) ; System . exit ( 0 ) ; } List < String > zipNames = new ArrayList < String > ( ) ; List < String > jarNames = new ArrayList < String > ( ) ; String destDir = null ; boolean jarActive = false , zipActive = false , destDirActiv... | Main command line entry point . |
126,616 | public String getMessage ( ) { String base = super . getMessage ( ) ; if ( null == base ) { return "Failed to access " + m_variable + " environment variable" ; } return "Failed to access " + m_variable + " environment variable - " + base ; } | Prepends variable name to the base message . |
126,617 | public void notifyUpdate ( URL resource , int expected , int count ) { if ( m_first ) { m_expected = expected ; m_start = System . currentTimeMillis ( ) ; m_first = false ; } int completed = ( count * 100 ) / expected ; m_out . print ( resource . toExternalForm ( ) + " : " + completed + "% \r" ) ; } | Notify the monitor of the update in the download status . |
126,618 | public void notifyCompletion ( URL resource ) { long now = System . currentTimeMillis ( ) ; long time = now - m_start ; int kBps = ( int ) ( m_expected / time ) ; m_out . println ( resource . toExternalForm ( ) + " : " + kBps + " kBps. " ) ; } | Notify the monitor of the successful completion of a download process . |
126,619 | private static void processToken ( String token , Stack < String > stack , Properties props ) { if ( "}" . equals ( token ) ) { String name = stack . pop ( ) ; String open = stack . pop ( ) ; if ( "${" . equals ( open ) ) { startProperty ( name , props , stack ) ; } else { push ( stack , "${" + name + "}" ) ; } } else ... | Process one token . |
126,620 | private static void startProperty ( String name , Properties props , Stack < String > stack ) { String propValue = System . getProperty ( name ) ; if ( propValue == null ) { propValue = props . getProperty ( name ) ; } if ( propValue == null ) { push ( stack , "${" + name + "}" ) ; } else { push ( stack , propValue ) ;... | Starts a new property . |
126,621 | private static void push ( Stack < String > stack , String value ) { if ( stack . size ( ) > 0 ) { String data = stack . pop ( ) ; if ( "${" . equals ( data ) ) { stack . push ( data ) ; stack . push ( value ) ; } else { stack . push ( data + value ) ; } } else { stack . push ( value ) ; } } | Pushes a value on a stack |
126,622 | public void notifyUpdate ( URL resource , int expected , int count ) { synchronized ( m_Monitors ) { for ( StreamMonitor monitor : m_Monitors ) { monitor . notifyUpdate ( resource , expected , count ) ; } } } | Notify all subscribing monitors of a updated event . |
126,623 | public void notifyCompletion ( URL resource ) { synchronized ( m_Monitors ) { for ( StreamMonitor monitor : m_Monitors ) { monitor . notifyCompletion ( resource ) ; } } } | Notify all subscribing monitors of a download completion event . |
126,624 | private static void closeStreams ( InputStream src , OutputStream dest ) { try { src . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } try { dest . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } | Closes the streams and reports Exceptions to System . err |
126,625 | public static boolean compareStreams ( InputStream in1 , InputStream in2 ) throws IOException { boolean moreOnIn1 ; do { int v1 = in1 . read ( ) ; int v2 = in2 . read ( ) ; if ( v1 != v2 ) { return false ; } moreOnIn1 = v1 != - 1 ; } while ( moreOnIn1 ) ; boolean noMoreOnIn2Either = in2 . read ( ) == - 1 ; return noMor... | Compares if two streams are identical in their contents . |
126,626 | public static void copyReaderToWriter ( Reader input , Writer output , boolean close ) throws IOException { try { BufferedReader in = bufferInput ( input ) ; BufferedWriter out = bufferOutput ( output ) ; int ch = in . read ( ) ; while ( ch != - 1 ) { out . write ( ch ) ; ch = in . read ( ) ; } out . flush ( ) ; out . ... | Copies the Reader to the Writer . |
126,627 | private static BufferedWriter bufferOutput ( Writer writer ) { BufferedWriter out ; if ( writer instanceof BufferedWriter ) { out = ( BufferedWriter ) writer ; } else { out = new BufferedWriter ( writer ) ; } return out ; } | Wraps the Writer in a BufferedWriter unless it already is a BufferedWriter . |
126,628 | private static BufferedReader bufferInput ( Reader reader ) { BufferedReader in ; if ( reader instanceof BufferedReader ) { in = ( BufferedReader ) reader ; } else { in = new BufferedReader ( reader ) ; } return in ; } | Wraps the Reader in a BufferedReaderm unless it already is a BufferedReader . |
126,629 | public static void copyStreamToWriter ( InputStream in , Writer out , String encoding , boolean close ) throws IOException { InputStreamReader reader = new InputStreamReader ( in , encoding ) ; copyReaderToWriter ( reader , out , close ) ; } | Copies an InputStream to a Writer . |
126,630 | public static void copyReaderToStream ( Reader in , OutputStream out , String encoding , boolean close ) throws IOException { OutputStreamWriter writer = new OutputStreamWriter ( out , encoding ) ; copyReaderToWriter ( in , writer , close ) ; } | Copies the content of the Reader to the provided OutputStream using the provided encoding . |
126,631 | public PKSigningInformation loadSigningInformationFromPKCS12AndIntermediateCertificate ( InputStream keyStoreInputStream , String keyStorePassword , InputStream appleWWDRCAFileInputStream ) throws IOException , CertificateException { KeyStore pkcs12KeyStore = loadPKCS12File ( keyStoreInputStream , keyStorePassword ) ; ... | Load all signing information necessary for pass generation using two input streams for the key store and the Apple WWDRCA certificate . |
126,632 | public KeyStore loadPKCS12File ( InputStream inputStreamOfP12 , String password ) throws CertificateException , IOException { try { return CertUtils . toKeyStore ( inputStreamOfP12 , password . toCharArray ( ) ) ; } catch ( IllegalStateException ex ) { throw new IOException ( "Key from the input stream could not be dec... | Load the keystore from an already opened input stream . |
126,633 | public X509Certificate loadDERCertificate ( String filePath ) throws IOException , CertificateException { try ( InputStream certificateInputStream = CertUtils . toInputStream ( filePath ) ) { return loadDERCertificate ( certificateInputStream ) ; } } | Load certificate file in DER format from the filesystem or the classpath |
126,634 | public void visitClassContext ( ClassContext classContext ) { try { stack = new OpcodeStack ( ) ; suspectLocals = new HashMap < > ( ) ; classVersion = classContext . getJavaClass ( ) . getMajor ( ) ; super . visitClassContext ( classContext ) ; } finally { stack = null ; suspectLocals = null ; } } | implements the visitor to create and clear the stack and suspectLocals |
126,635 | public void visitMethod ( Method obj ) { suspectLocals . clear ( ) ; int [ ] parmRegs = RegisterUtils . getParameterRegisters ( obj ) ; for ( int pr : parmRegs ) { suspectLocals . put ( Integer . valueOf ( pr ) , new RegisterInfo ( RegisterUtils . getLocalVariableEndRange ( obj . getLocalVariableTable ( ) , pr , 0 ) ) ... | implements the visitor to collect parameter registers |
126,636 | public void visitCode ( Code obj ) { forLoops = new HashSet < > ( ) ; super . visitCode ( obj ) ; forLoops = null ; } | implements the visitor to clear the forLoops set |
126,637 | public void sawOpcode ( int seen ) { if ( ! forLoops . isEmpty ( ) ) { Iterator < FloatForLoop > ffl = forLoops . iterator ( ) ; while ( ffl . hasNext ( ) ) { if ( ! ffl . next ( ) . sawOpcode ( seen ) ) { ffl . remove ( ) ; } } } if ( OpcodeUtils . isFLoad ( seen ) || OpcodeUtils . isDLoad ( seen ) ) { forLoops . add ... | implements the visitor to find for loops using floating point indexes |
126,638 | public void visitField ( Field obj ) { String fieldSig = obj . getSignature ( ) ; if ( "Ljavax/swing/JLabel;" . equals ( fieldSig ) ) { FieldAnnotation fa = FieldAnnotation . fromVisitedField ( this ) ; fieldLabels . add ( XFactory . createXField ( fa ) ) ; } } | looks for fields that are JLabels and stores them in a set |
126,639 | private void processFaultyGuiStrings ( ) { FQMethod methodInfo = new FQMethod ( getClassConstantOperand ( ) , getNameConstantOperand ( ) , getSigConstantOperand ( ) ) ; Integer parmIndex = displayTextMethods . get ( methodInfo ) ; if ( ( parmIndex != null ) && ( stack . getStackDepth ( ) > parmIndex . intValue ( ) ) ) ... | looks for calls to set a readable string that is generated from a static constant as these strings are not translatable . also looks for setting readable strings that are appended together . This is likely not to be internationalizable . |
126,640 | private void processNullLayouts ( String className , String methodName ) { if ( "java/awt/Container" . equals ( className ) && "setLayout" . equals ( methodName ) && ( stack . getStackDepth ( ) > 0 ) && stack . getStackItem ( 0 ) . isNull ( ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . S508C_NULL_L... | looks for containers where a null layout is installed |
126,641 | private void processSetColorOps ( String methodName ) throws ClassNotFoundException { if ( "setBackground" . equals ( methodName ) || "setForeground" . equals ( methodName ) ) { int argCount = SignatureUtils . getNumParameters ( getSigConstantOperand ( ) ) ; if ( stack . getStackDepth ( ) > argCount ) { OpcodeStack . I... | looks for calls to set the color of components where the color isn t from UIManager |
126,642 | private void processSetSizeOps ( String methodName ) throws ClassNotFoundException { if ( "setSize" . equals ( methodName ) ) { int argCount = SignatureUtils . getNumParameters ( getSigConstantOperand ( ) ) ; if ( ( windowClass != null ) && ( stack . getStackDepth ( ) > argCount ) ) { OpcodeStack . Item item = stack . ... | looks for calls to setSize on components rather than letting the layout manager set them |
126,643 | public static int getAStoreReg ( final DismantleBytecode dbc , final int seen ) { if ( seen == Const . ASTORE ) { return dbc . getRegisterOperand ( ) ; } if ( OpcodeUtils . isAStore ( seen ) ) { return seen - Const . ASTORE_0 ; } return - 1 ; } | returns the register used to store a reference |
126,644 | public static int getALoadReg ( DismantleBytecode dbc , int seen ) { if ( seen == Const . ALOAD ) { return dbc . getRegisterOperand ( ) ; } if ( OpcodeUtils . isALoad ( seen ) ) { return seen - Const . ALOAD_0 ; } return - 1 ; } | returns the register used to load a reference |
126,645 | public static int getStoreReg ( DismantleBytecode dbc , int seen ) { if ( ( seen == Const . ASTORE ) || ( seen == Const . ISTORE ) || ( seen == Const . LSTORE ) || ( seen == Const . FSTORE ) || ( seen == Const . DSTORE ) ) { return dbc . getRegisterOperand ( ) ; } if ( OpcodeUtils . isIStore ( seen ) ) { return seen - ... | returns the register used in a store operation |
126,646 | public static int getLoadReg ( DismantleBytecode dbc , int seen ) { if ( ( seen == Const . ALOAD ) || ( seen == Const . ILOAD ) || ( seen == Const . LLOAD ) || ( seen == Const . FLOAD ) || ( seen == Const . DLOAD ) ) { return dbc . getRegisterOperand ( ) ; } if ( OpcodeUtils . isILoad ( seen ) ) { return seen - Const .... | returns the register used in a load operation |
126,647 | public static int getLocalVariableEndRange ( LocalVariableTable lvt , int reg , int curPC ) { int endRange = Integer . MAX_VALUE ; if ( lvt != null ) { LocalVariable lv = lvt . getLocalVariable ( reg , curPC ) ; if ( lv != null ) { endRange = lv . getStartPC ( ) + lv . getLength ( ) ; } } return endRange ; } | returns the end pc of the visible range of this register at this pc |
126,648 | public static int [ ] getParameterRegisters ( Method obj ) { Type [ ] argTypes = obj . getArgumentTypes ( ) ; int [ ] regs = new int [ argTypes . length ] ; int curReg = obj . isStatic ( ) ? 0 : 1 ; for ( int t = 0 ; t < argTypes . length ; t ++ ) { String sig = argTypes [ t ] . getSignature ( ) ; regs [ t ] = curReg ;... | gets the set of registers used for parameters |
126,649 | public void visitCode ( Code obj ) { if ( ! Values . STATIC_INITIALIZER . equals ( getMethodName ( ) ) ) { state = State . SEEN_NOTHING ; super . visitCode ( obj ) ; } } | implements the visitor by forwarding calls for methods that are the static initializer |
126,650 | public void sawOpcode ( int seen ) { int index ; switch ( state ) { case SEEN_NOTHING : if ( seen == Const . BIPUSH ) { arraySize = getIntConstant ( ) ; if ( arraySize > 0 ) { state = State . SEEN_ARRAY_SIZE ; } } else if ( ( seen >= Const . ICONST_M1 ) && ( seen <= Const . ICONST_5 ) ) { arraySize = seen - Const . ICO... | implements the visitor to look for creation of local arrays using constant values |
126,651 | public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; if ( ( serializableClass != null ) && ( cls . implementationOf ( serializableClass ) ) ) { Field [ ] fields = cls . getFields ( ) ; setupVisitorForClass ( cls ) ; for ( Field f : fields ) { if ( ! f . i... | checks to see if the class is Serializable then looks for fields that are both final and transient |
126,652 | public void visitCode ( Code obj ) { Method m = getMethod ( ) ; stack . resetForMethodEntry ( this ) ; initializedRegs . clear ( ) ; modifyRegs . clear ( ) ; Type [ ] argTypes = m . getArgumentTypes ( ) ; int arg = m . isStatic ( ) ? 0 : 1 ; for ( Type argType : argTypes ) { String argSig = argType . getSignature ( ) ;... | overrides the visitor to collect parameter registers |
126,653 | public void visitClassContext ( ClassContext classContext ) { try { int majorVersion = classContext . getJavaClass ( ) . getMajor ( ) ; if ( majorVersion >= Const . MAJOR_1_4 ) { fbInfo = new ArrayList < > ( ) ; super . visitClassContext ( classContext ) ; } } finally { fbInfo = null ; } } | overrides the visitor to check for java class version being as good or better than 1 . 4 |
126,654 | public void visitCode ( Code obj ) { fbInfo . clear ( ) ; loadedReg = - 1 ; CodeException [ ] exc = obj . getExceptionTable ( ) ; if ( exc != null ) { for ( CodeException ce : exc ) { if ( ( ce . getCatchType ( ) == 0 ) && ( ce . getStartPC ( ) == ce . getHandlerPC ( ) ) ) { fbInfo . add ( new FinallyBlockInfo ( ce . g... | overrides the visitor to collect finally block info . |
126,655 | private static Method findMethod ( JavaClass cls , String name , String sig ) { Method [ ] methods = cls . getMethods ( ) ; for ( Method m : methods ) { if ( m . getName ( ) . equals ( name ) && m . getSignature ( ) . equals ( sig ) ) { return m ; } } return null ; } | finds the method in specified class by name and signature |
126,656 | public boolean prescreen ( Method method ) { if ( Values . STATIC_INITIALIZER . equals ( method . getName ( ) ) ) { return false ; } BitSet bytecodeSet = getClassContext ( ) . getBytecodeSet ( method ) ; return ( bytecodeSet != null ) && ( bytecodeSet . get ( Const . ATHROW ) ) ; } | looks for methods that contain a ATHROW opcodes ignoring static initializers |
126,657 | public void visitCode ( Code obj ) { Method method = getMethod ( ) ; if ( ! method . isSynthetic ( ) && prescreen ( method ) ) { stack . resetForMethodEntry ( this ) ; super . visitCode ( obj ) ; } } | overrides the visitor to prescreen the method to look for throws calls and only forward onto bytecode scanning if there |
126,658 | public void sawOpcode ( int seen ) { boolean allConstantStrings = false ; boolean sawConstant = false ; try { stack . precomputation ( this ) ; if ( seen == Const . ATHROW ) { checkForWEM ( ) ; } else if ( ( seen == Const . LDC ) || ( seen == Const . LDC_W ) ) { if ( getConstantRefOperand ( ) instanceof ConstantString ... | overrides the visitor to look for throws instructions using exceptions with static messages |
126,659 | public static void main ( final String [ ] args ) { JOptionPane . showMessageDialog ( null , "To use fb-contrib, copy this jar file into your local SpotBugs plugin directory, and use SpotBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com" , "fb-contrib: copyright 2005-2019" , JOptionPane . INFORMATION_MESSA... | shows the simple help |
126,660 | public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; for ( CompareSpec entry : compareClasses ) { if ( cls . implementationOf ( entry . getCompareClass ( ) ) ) { methodInfo = entry . getMethodInfo ( ) ; stack = new OpcodeStack ( ) ; super . visitClassCont... | implements the visitor to actually iterate twice over this class once for compareTo and once for compare . |
126,661 | public void visitCode ( Code obj ) { if ( getMethod ( ) . isSynthetic ( ) ) { return ; } String methodName = getMethodName ( ) ; String methodSig = getMethodSig ( ) ; if ( methodName . equals ( methodInfo . methodName ) && methodSig . endsWith ( methodInfo . signatureEnding ) && ( SignatureUtils . getNumParameters ( me... | implements the visitor to check to see what Const were returned from a comparator . If no Const were returned it can t determine anything however if only Const were returned it looks to see if negative positive and zero was returned . It also looks to see if a non zero value is returned unconditionally . While it is po... |
126,662 | public void sawOpcode ( int seen ) { try { stack . precomputation ( this ) ; switch ( seen ) { case Const . IRETURN : { processIntegerReturn ( ) ; } break ; case Const . GOTO : case Const . GOTO_W : { if ( stack . getStackDepth ( ) > 0 ) { throw new StopOpcodeParsingException ( ) ; } if ( furthestBranchTarget < getBran... | implements the visitor to look for returns of constant values and records them for being negative zero or positive . It also records unconditional returns of non zero values |
126,663 | public void visitCode ( final Code obj ) { stack . resetForMethodEntry ( this ) ; indexToFieldMap . clear ( ) ; super . visitCode ( obj ) ; } | implements the visitor to reset the opcode stack and the file maps |
126,664 | private int getIntOpRegister ( final int seen ) { if ( ( seen == Const . ISTORE ) || ( seen == Const . IINC ) ) { return getRegisterOperand ( ) ; } return seen - Const . ISTORE_0 ; } | fetch the register from a integer op code |
126,665 | public void visitClassContext ( ClassContext classContext ) { try { JavaClass cls = classContext . getJavaClass ( ) ; if ( cls . getMajor ( ) >= Const . MAJOR_1_5 ) { stack = new OpcodeStack ( ) ; checkedFields = new HashSet < > ( ) ; enumRegs = new HashMap < > ( ) ; enumFields = new HashMap < > ( ) ; super . visitClas... | implements the visitor to check that the class is greater or equal than 1 . 5 and set and clear the stack |
126,666 | private boolean isEnum ( int stackPos ) throws ClassNotFoundException { if ( stack . getStackDepth ( ) <= stackPos ) { return false ; } OpcodeStack . Item item = stack . getStackItem ( stackPos ) ; if ( ! item . getSignature ( ) . startsWith ( Values . SIG_QUALIFIED_CLASS_PREFIX ) ) { return false ; } JavaClass cls = i... | returns whether the item at the stackPos location on the stack is an enum and doesn t implement any interfaces |
126,667 | private boolean couldBeEnumCollection ( int stackPos ) { if ( stack . getStackDepth ( ) <= stackPos ) { return false ; } OpcodeStack . Item item = stack . getStackItem ( stackPos ) ; CollectionType userValue = ( CollectionType ) item . getUserValue ( ) ; if ( userValue != null ) { return userValue == CollectionType . R... | returns whether the item at the stackpos location isn t an enum collection but could be |
126,668 | private boolean alreadyReported ( int stackPos ) { if ( stack . getStackDepth ( ) <= stackPos ) { return false ; } OpcodeStack . Item item = stack . getStackItem ( stackPos ) ; XField field = item . getXField ( ) ; if ( field == null ) { return false ; } String fieldName = field . getName ( ) ; return ! checkedFields .... | returns whether the collection has already been reported on |
126,669 | public void visitCode ( Code obj ) { try { XMethod xMethod = getXMethod ( ) ; if ( xMethod != null ) { String [ ] tes = xMethod . getThrownExceptions ( ) ; Set < String > thrownExceptions = new HashSet < > ( Arrays . < String > asList ( ( tes == null ) ? new String [ 0 ] : tes ) ) ; blocks = new ArrayList < > ( ) ; inB... | overrides the visitor to look for idea try catch blocks to find issues specifically method needs two or more try catch blocks that only catch one exception type . |
126,670 | private TryBlock findBlockWithStart ( int pc ) { for ( TryBlock block : blocks ) { if ( block . atStartPC ( pc ) ) { return block ; } } return null ; } | looks for an existing try block that has this pc as a start of the try |
126,671 | public void visit ( Method obj ) { state = State . SAW_NOTHING ; register1_1 = - 1 ; register1_2 = - 1 ; register2_1 = - 1 ; register2_2 = - 1 ; super . visit ( obj ) ; } | overrides the visitor to reset the registers |
126,672 | public void sawOpcode ( int seen ) { switch ( state ) { case SAW_NOTHING : if ( OpcodeUtils . isALoad ( seen ) ) { register1_1 = RegisterUtils . getALoadReg ( this , seen ) ; state = State . SAW_LOAD1_1 ; } break ; case SAW_LOAD1_1 : if ( OpcodeUtils . isALoad ( seen ) ) { register1_2 = RegisterUtils . getALoadReg ( th... | overrides the visitor to look for double date compares using the same registers |
126,673 | protected final int isLocalCollection ( OpcodeStack . Item item ) throws ClassNotFoundException { Comparable < ? > aliasReg = ( Comparable < ? > ) item . getUserValue ( ) ; if ( aliasReg instanceof Integer ) { return ( ( Integer ) aliasReg ) . intValue ( ) ; } int reg = item . getRegisterNumber ( ) ; if ( reg < 0 ) { r... | determines if the stack item refers to a collection that is stored in a local variable |
126,674 | public void visitClassContext ( ClassContext classContext ) { try { localizableFields = new HashMap < > ( ) ; visitedBlocks = new BitSet ( ) ; clsContext = classContext ; clsName = clsContext . getJavaClass ( ) . getClassName ( ) ; clsSig = SignatureUtils . classToSignature ( clsName ) ; JavaClass cls = classContext . ... | overrides the visitor to collect localizable fields and then report those that survive all method checks . |
126,675 | public void visitMethod ( Method obj ) { if ( localizableFields . isEmpty ( ) ) { return ; } try { cfg = clsContext . getCFG ( obj ) ; cpg = cfg . getMethodGen ( ) . getConstantPool ( ) ; BasicBlock bb = cfg . getEntry ( ) ; Set < String > uncheckedFields = new HashSet < > ( localizableFields . keySet ( ) ) ; visitedBl... | overrides the visitor to navigate basic blocks looking for all first usages of fields removing those that are read from first . |
126,676 | private boolean prescreen ( Method method ) { BitSet bytecodeSet = getClassContext ( ) . getBytecodeSet ( method ) ; return ( bytecodeSet != null ) && ( bytecodeSet . get ( Const . PUTFIELD ) || bytecodeSet . get ( Const . GETFIELD ) ) ; } | looks for methods that contain a GETFIELD or PUTFIELD opcodes |
126,677 | public void sawOpcode ( int seen ) { if ( ( seen == Const . GETFIELD ) || ( seen == Const . PUTFIELD ) ) { String fieldName = getNameConstantOperand ( ) ; FieldInfo fi = localizableFields . get ( fieldName ) ; if ( fi != null ) { SourceLineAnnotation sla = SourceLineAnnotation . fromVisitedInstruction ( this ) ; fi . s... | implements the visitor to add SourceLineAnnotations for fields in constructors and static initializers . |
126,678 | private void buildMethodFieldModifiers ( ClassContext classContext ) { FieldModifier fm = new FieldModifier ( ) ; fm . visitClassContext ( classContext ) ; methodFieldModifiers = fm . getMethodFieldModifiers ( ) ; } | builds up the method to field map of what method write to which fields this is one recursively so that if method A calls method B and method B writes to field C then A modifies F . |
126,679 | public void visitClassContext ( ClassContext classContext ) { if ( mapInterface != null ) { this . clsContext = classContext ; classContext . getJavaClass ( ) . accept ( this ) ; } } | overrides the visitor to make sure that the static initializer was able to load the map class |
126,680 | public void visitField ( Field obj ) { if ( checkConfusedName ( obj . getName ( ) , obj . getSignature ( ) ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . CNC_COLLECTION_NAMING_CONFUSION . name ( ) , NORMAL_PRIORITY ) . addClass ( this ) . addField ( this ) . addString ( obj . getName ( ) ) ) ; } } | overrides the visitor to look for fields where the name has Map Set List in it but the type of that field isn t that . |
126,681 | public void visitMethod ( Method obj ) { LocalVariableTable lvt = obj . getLocalVariableTable ( ) ; if ( lvt != null ) { LocalVariable [ ] lvs = lvt . getLocalVariableTable ( ) ; for ( LocalVariable lv : lvs ) { if ( checkConfusedName ( lv . getName ( ) , lv . getSignature ( ) ) ) { bugReporter . reportBug ( new BugIns... | overrides the visitor to look for local variables where the name has Map Set List in it but the type of that field isn t that . note that this only is useful if compiled with debug labels . |
126,682 | @ edu . umd . cs . findbugs . annotations . SuppressFBWarnings ( value = "EXS_EXCEPTION_SOFTENING_RETURN_FALSE" , justification = "No other simple way to determine whether class exists" ) private boolean checkConfusedName ( String methodOrVariableName , String signature ) { try { String name = methodOrVariableName . to... | looks for a name that mentions a collection type but the wrong type for the variable |
126,683 | public void sawOpcode ( int seen ) { Units unit = null ; try { stack . precomputation ( this ) ; switch ( seen ) { case Const . INVOKEVIRTUAL : case Const . INVOKEINTERFACE : case Const . INVOKESTATIC : unit = processInvoke ( ) ; break ; case Const . GETSTATIC : String clsName = getClassConstantOperand ( ) ; if ( "java... | overrides the visitor to look for operations on two time unit values that are conflicting |
126,684 | @ SuppressWarnings ( "PMD.CompareObjectsWithEquals" ) private void processArithmetic ( ) { if ( stack . getStackDepth ( ) > 1 ) { OpcodeStack . Item arg1 = stack . getStackItem ( 0 ) ; OpcodeStack . Item arg2 = stack . getStackItem ( 1 ) ; Units u1 = ( Units ) arg1 . getUserValue ( ) ; Units u2 = ( Units ) arg2 . getUs... | false positive ; we re comparing enums |
126,685 | public void visitClassContext ( ClassContext classContext ) { try { if ( ( throwableClass != null ) && ! isPre14Class ( classContext . getJavaClass ( ) ) ) { stack = new OpcodeStack ( ) ; catchInfos = new HashSet < > ( ) ; exReg = new HashMap < > ( ) ; super . visitClassContext ( classContext ) ; } } finally { stack = ... | implements the visitor to make sure the jdk is 1 . 4 or better |
126,686 | public boolean prescreen ( Code code , Method method ) { if ( method . isSynthetic ( ) ) { return false ; } CodeException [ ] ce = code . getExceptionTable ( ) ; if ( CollectionUtils . isEmpty ( ce ) ) { return false ; } BitSet bytecodeSet = getClassContext ( ) . getBytecodeSet ( method ) ; return ( bytecodeSet != null... | looks for methods that contain a catch block and an ATHROW opcode |
126,687 | public void visitCode ( Code obj ) { if ( prescreen ( obj , getMethod ( ) ) ) { stack . resetForMethodEntry ( this ) ; catchInfos . clear ( ) ; exceptions = collectExceptions ( obj . getExceptionTable ( ) ) ; exReg . clear ( ) ; lastWasExitPoint = false ; super . visitCode ( obj ) ; } } | implements the visitor to filter out methods that don t throw exceptions |
126,688 | public CodeException [ ] collectExceptions ( CodeException ... exs ) { List < CodeException > filteredEx = new ArrayList < > ( ) ; for ( CodeException ce : exs ) { if ( ( ce . getCatchType ( ) != 0 ) && ( ce . getStartPC ( ) < ce . getEndPC ( ) ) && ( ce . getEndPC ( ) <= ce . getHandlerPC ( ) ) ) { filteredEx . add ( ... | collects all the valid exception objects ( ones where start and finish are before the target |
126,689 | public boolean isPossibleExBuilder ( int excReg ) throws ClassNotFoundException { String sig = getSigConstantOperand ( ) ; String returnSig = SignatureUtils . getReturnSignature ( sig ) ; if ( returnSig . startsWith ( Values . SIG_QUALIFIED_CLASS_PREFIX ) ) { returnSig = SignatureUtils . trimSignature ( returnSig ) ; J... | returns whether the method called might be a method that builds an exception using the original exception . It does so by looking to see if the method returns an exception and if one of the parameters is the original exception |
126,690 | private boolean updateExceptionRegister ( CatchInfo ci , int seen , int pc ) { if ( OpcodeUtils . isAStore ( seen ) ) { int reg = RegisterUtils . getAStoreReg ( this , seen ) ; ci . setReg ( reg ) ; exReg . put ( Integer . valueOf ( reg ) , Boolean . TRUE ) ; LocalVariableTable lvt = getMethod ( ) . getLocalVariableTab... | looks to update the catchinfo block with the register used for the exception variable . If their is a local variable table but the local variable can t be found return false signifying an empty catch block . |
126,691 | private void addCatchBlock ( int start , int finish ) { CatchInfo ci = new CatchInfo ( start , finish ) ; catchInfos . add ( ci ) ; } | add a catch block info record for the catch block that is guessed to be in the range of start to finish |
126,692 | public void visitClassContext ( ClassContext classContext ) { try { javaClass = classContext . getJavaClass ( ) ; if ( javaClass . getMajor ( ) >= Const . MAJOR_1_5 ) { javaClass . accept ( this ) ; } } finally { javaClass = null ; } } | overrides the visitor to make sure that the class was compiled by java 1 . 5 or later . |
126,693 | public void visitMethod ( Method obj ) { try { if ( obj . isSynthetic ( ) ) { return ; } if ( Values . CONSTRUCTOR . equals ( getMethodName ( ) ) && javaClass . getClassName ( ) . contains ( "$" ) ) { return ; } List < String > types = SignatureUtils . getParameterSignatures ( obj . getSignature ( ) ) ; if ( ( types . ... | overrides the visitor to look for methods that has an array as a last parameter of an array type where the base type is not like the previous parameter nor something like a char or byte array . |
126,694 | @ edu . umd . cs . findbugs . annotations . SuppressFBWarnings ( value = "LII_LIST_INDEXED_ITERATING" , justification = "this doesn't iterate over every element, so we can't use a for-each loop" ) private static boolean hasSimilarParms ( List < String > argTypes ) { for ( int i = 0 ; i < ( argTypes . size ( ) - 1 ) ; i... | determines whether a bunch of types are similar and thus would be confusing to have one be a varargs . |
126,695 | private boolean isInherited ( Method m ) throws ClassNotFoundException { JavaClass [ ] infs = javaClass . getAllInterfaces ( ) ; for ( JavaClass inf : infs ) { if ( hasMethod ( inf , m ) ) { return true ; } } JavaClass [ ] sups = javaClass . getSuperClasses ( ) ; for ( JavaClass sup : sups ) { if ( hasMethod ( sup , m ... | looks to see if this method is derived from a super class . If it is we don t want to report on it as that would entail changing a whole hierarchy |
126,696 | private static boolean hasMethod ( JavaClass c , Method candidateMethod ) { String name = candidateMethod . getName ( ) ; String sig = candidateMethod . getSignature ( ) ; for ( Method method : c . getMethods ( ) ) { if ( ! method . isStatic ( ) && method . getName ( ) . equals ( name ) && method . getSignature ( ) . e... | looks to see if a class has a method with a specific name and signature |
126,697 | public void visitClassContext ( ClassContext context ) { JavaClass cls = context . getJavaClass ( ) ; if ( ! isInternal ( cls . getClassName ( ) ) ) { ConstantPool pool = cls . getConstantPool ( ) ; int numItems = pool . getLength ( ) ; for ( int i = 0 ; i < numItems ; i ++ ) { Constant c = pool . getConstant ( i ) ; i... | implements the visitor to look for classes that reference com . sun . xxx or org . apache . xerces . xxx classes by looking for class Const in the constant pool |
126,698 | private static boolean isInternal ( String clsName ) { boolean internal = false ; for ( String internalPackage : internalPackages ) { if ( clsName . startsWith ( internalPackage ) ) { internal = true ; break ; } } if ( internal ) { for ( String externalPackage : externalPackages ) { if ( clsName . startsWith ( external... | determines if the class in question is an internal class by looking at package prefixes |
126,699 | private Set < String > getDependenciesForClass ( String clsName ) { Set < String > dependencies = dependencyGraph . get ( clsName ) ; if ( dependencies == null ) { dependencies = new HashSet < > ( ) ; dependencyGraph . put ( clsName , dependencies ) ; } return dependencies ; } | returns a set of dependent class names for a class and if it doesn t exist create the set install it and then return ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.