Input: Finds macros end . [CODESPLIT] protected int findMacroEnd ( final String template , final int fromIndex ) { int endIndex = template . indexOf ( ' ' , fromIndex ) ; if ( endIndex == - 1 ) { throw new DbSqlBuilderException ( "Template syntax error, some macros are not closed. Error at: '..." + template . substring ( fromIndex ) ) ; } return endIndex ; }


Input: Count escapes to the left . [CODESPLIT] protected int countEscapes ( final String template , int macroIndex ) { macroIndex -- ; int escapeCount = 0 ; while ( macroIndex >= 0 ) { if ( template . charAt ( macroIndex ) != ESCAPE_CHARACTER ) { break ; } escapeCount ++ ; macroIndex -- ; } return escapeCount ; }


Input: ---------------------------------------------------------------- handlers [CODESPLIT] protected void onTable ( final DbSqlBuilder sqlBuilder , final String allTables ) { String [ ] tables = StringUtil . split ( allTables , StringPool . COMMA ) ; for ( String table : tables ) { sqlBuilder . table ( table ) ; } }


Input: Builds a query string from given query map . [CODESPLIT] public static String buildQuery ( final HttpMultiMap < ? > queryMap , final String encoding ) { if ( queryMap . isEmpty ( ) ) { return StringPool . EMPTY ; } int queryMapSize = queryMap . size ( ) ; StringBand query = new StringBand ( queryMapSize * 4 ) ; int count = 0 ; for ( Map . Entry < String , ? > entry : queryMap ) { String key = entry . getKey ( ) ; key = URLCoder . encodeQueryParam ( key , encoding ) ; Object value = entry . getValue ( ) ; if ( value == null ) { if ( count != 0 ) { query . append ( ' ' ) ; } query . append ( key ) ; count ++ ; } else { if ( count != 0 ) { query . append ( ' ' ) ; } query . append ( key ) ; count ++ ; query . append ( ' ' ) ; String valueString = URLCoder . encodeQueryParam ( value . toString ( ) , encoding ) ; query . append ( valueString ) ; } } return query . toString ( ) ; }


Input: Parses query from give query string . Values are optionally decoded . [CODESPLIT] public static HttpMultiMap < String > parseQuery ( final String query , final boolean decode ) { final HttpMultiMap < String > queryMap = HttpMultiMap . newCaseInsensitiveMap ( ) ; if ( StringUtil . isBlank ( query ) ) { return queryMap ; } int lastNdx = 0 ; while ( lastNdx < query . length ( ) ) { int ndx = query . indexOf ( ' ' , lastNdx ) ; if ( ndx == - 1 ) { ndx = query . length ( ) ; } final String paramAndValue = query . substring ( lastNdx , ndx ) ; ndx = paramAndValue . indexOf ( ' ' ) ; if ( ndx == - 1 ) { queryMap . add ( paramAndValue , null ) ; } else { String name = paramAndValue . substring ( 0 , ndx ) ; if ( decode ) { name = URLDecoder . decodeQuery ( name ) ; } String value = paramAndValue . substring ( ndx + 1 ) ; if ( decode ) { value = URLDecoder . decodeQuery ( value ) ; } queryMap . add ( name , value ) ; } lastNdx += paramAndValue . length ( ) + 1 ; } return queryMap ; }


Input: Makes nice header names . [CODESPLIT] public static String prepareHeaderParameterName ( final String headerName ) { // special cases if ( headerName . equals ( "etag" ) ) { return HttpBase . HEADER_ETAG ; } if ( headerName . equals ( "www-authenticate" ) ) { return "WWW-Authenticate" ; } char [ ] name = headerName . toCharArray ( ) ; boolean capitalize = true ; for ( int i = 0 ; i < name . length ; i ++ ) { char c = name [ i ] ; if ( c == ' ' ) { capitalize = true ; continue ; } if ( capitalize ) { name [ i ] = Character . toUpperCase ( c ) ; capitalize = false ; } else { name [ i ] = Character . toLowerCase ( c ) ; } } return new String ( name ) ; }


Input: Extracts media - type from value of Content Type header . [CODESPLIT] public static String extractMediaType ( final String contentType ) { int index = contentType . indexOf ( ' ' ) ; if ( index == - 1 ) { return contentType ; } return contentType . substring ( 0 , index ) ; }


Input: Extracts header parameter . Returns <code > null< / code > if parameter not found . [CODESPLIT] public static String extractHeaderParameter ( final String header , final String parameter , final char separator ) { int index = 0 ; while ( true ) { index = header . indexOf ( separator , index ) ; if ( index == - 1 ) { return null ; } index ++ ; // skip whitespaces while ( index < header . length ( ) && header . charAt ( index ) == ' ' ) { index ++ ; } int eqNdx = header . indexOf ( ' ' , index ) ; if ( eqNdx == - 1 ) { return null ; } String paramName = header . substring ( index , eqNdx ) ; eqNdx ++ ; if ( ! paramName . equalsIgnoreCase ( parameter ) ) { index = eqNdx ; continue ; } int endIndex = header . indexOf ( ' ' , eqNdx ) ; if ( endIndex == - 1 ) { return header . substring ( eqNdx ) ; } else { return header . substring ( eqNdx , endIndex ) ; } } }


Input: Sets prepared statement object using target SQL type . Here Jodd makes conversion and not JDBC driver . See : http : // www . tutorialspoint . com / jdbc / jdbc - data - types . htm [CODESPLIT] public static void setPreparedStatementObject ( final PreparedStatement preparedStatement , final int index , final Object value , final int targetSqlType ) throws SQLException { if ( value == null ) { preparedStatement . setNull ( index , Types . NULL ) ; return ; } switch ( targetSqlType ) { case Types . VARCHAR : case Types . LONGVARCHAR : case Types . CHAR : preparedStatement . setString ( index , Converter . get ( ) . toString ( value ) ) ; break ; case Types . INTEGER : case Types . SMALLINT : case Types . TINYINT : preparedStatement . setInt ( index , Converter . get ( ) . toIntValue ( value ) ) ; break ; case Types . BIGINT : preparedStatement . setLong ( index , Converter . get ( ) . toLongValue ( value ) ) ; break ; case Types . BOOLEAN : case Types . BIT : preparedStatement . setBoolean ( index , Converter . get ( ) . toBooleanValue ( value ) ) ; break ; case Types . DATE : preparedStatement . setDate ( index , TypeConverterManager . get ( ) . convertType ( value , java . sql . Date . class ) ) ; break ; case Types . NUMERIC : case Types . DECIMAL : preparedStatement . setBigDecimal ( index , Converter . get ( ) . toBigDecimal ( value ) ) ; break ; case Types . DOUBLE : preparedStatement . setDouble ( index , Converter . get ( ) . toDoubleValue ( value ) ) ; break ; case Types . REAL : case Types . FLOAT : preparedStatement . setFloat ( index , Converter . get ( ) . toFloatValue ( value ) ) ; break ; case Types . TIME : preparedStatement . setTime ( index , TypeConverterManager . get ( ) . convertType ( value , java . sql . Time . class ) ) ; break ; case Types . TIMESTAMP : preparedStatement . setTimestamp ( index , TypeConverterManager . get ( ) . convertType ( value , Timestamp . class ) ) ; break ; case Types . BINARY : case Types . VARBINARY : preparedStatement . setBytes ( index , TypeConverterManager . get ( ) . convertType ( value , byte [ ] . class ) ) ; break ; default : if ( targetSqlType != SqlType . DB_SQLTYPE_NOT_AVAILABLE ) { preparedStatement . setObject ( index , value , targetSqlType ) ; } else { preparedStatement . setObject ( index , value ) ; } } }


Input: { [CODESPLIT] @ Override public boolean init ( final String actionPath , final String [ ] separators ) { String prefix = separators [ 0 ] ; String split = separators [ 1 ] ; String suffix = separators [ 2 ] ; macrosCount = StringUtil . count ( actionPath , prefix ) ; if ( macrosCount == 0 ) { return false ; } names = new String [ macrosCount ] ; patterns = new String [ macrosCount ] ; fixed = new String [ macrosCount + 1 ] ; int offset = 0 ; int i = 0 ; while ( true ) { int [ ] ndx = StringUtil . indexOfRegion ( actionPath , prefix , suffix , offset ) ; if ( ndx == null ) { break ; } fixed [ i ] = actionPath . substring ( offset , ndx [ 0 ] ) ; String name = actionPath . substring ( ndx [ 1 ] , ndx [ 2 ] ) ; // name:pattern String pattern = null ; int colonNdx = name . indexOf ( split ) ; if ( colonNdx != - 1 ) { pattern = name . substring ( colonNdx + 1 ) . trim ( ) ; name = name . substring ( 0 , colonNdx ) . trim ( ) ; } this . patterns [ i ] = pattern ; this . names [ i ] = name ; // iterate offset = ndx [ 3 ] ; i ++ ; } if ( offset < actionPath . length ( ) ) { fixed [ i ] = actionPath . substring ( offset ) ; } else { fixed [ i ] = StringPool . EMPTY ; } return true ; }


Input: { [CODESPLIT] @ Override public int match ( final String actionPath ) { String [ ] values = process ( actionPath , true ) ; if ( values == null ) { return - 1 ; } int macroChars = 0 ; for ( String value : values ) { if ( value != null ) { macroChars += value . length ( ) ; } } return actionPath . length ( ) - macroChars ; }


Input: Process action path in two modes : matching mode and extracting mode . [CODESPLIT] private String [ ] process ( final String actionPath , final boolean match ) { // first check the first fixed as a prefix if ( match && ! actionPath . startsWith ( fixed [ 0 ] ) ) { return null ; } String [ ] values = new String [ macrosCount ] ; int offset = fixed [ 0 ] . length ( ) ; int i = 0 ; while ( i < macrosCount ) { int nexti = i ; // defines next fixed string to match String nextFixed ; while ( true ) { nexti ++ ; if ( nexti > macrosCount ) { nextFixed = null ; // match to the end of line break ; } nextFixed = fixed [ nexti ] ; if ( nextFixed . length ( ) != 0 ) { break ; } // next fixed is an empty string, so skip the next macro. } // find next fixed string int ndx ; if ( nextFixed != null ) { ndx = actionPath . indexOf ( nextFixed , offset ) ; } else { ndx = actionPath . length ( ) ; } if ( ndx == - 1 ) { return null ; } String macroValue = actionPath . substring ( offset , ndx ) ; values [ i ] = macroValue ; if ( match && patterns [ i ] != null ) { if ( ! matchValue ( i , macroValue ) ) { return null ; } } if ( nextFixed == null ) { offset = ndx ; break ; } // iterate int nextFixedLength = nextFixed . length ( ) ; offset = ndx + nextFixedLength ; i = nexti ; } if ( offset != actionPath . length ( ) ) { // action path is not consumed fully during this matching return null ; } return values ; }


Input: Renders node to appendable . [CODESPLIT] public String toHtml ( final Node node , final Appendable appendable ) { NodeVisitor renderer = createRenderer ( appendable ) ; node . visit ( renderer ) ; return appendable . toString ( ) ; }


Input: Renders node children to appendable . [CODESPLIT] public String toInnerHtml ( final Node node , final Appendable appendable ) { NodeVisitor renderer = createRenderer ( appendable ) ; node . visitChildren ( renderer ) ; return appendable . toString ( ) ; }


Input: Returns <code > null< / code > for excluded HTTP headers . [CODESPLIT] @ Override public String getHeader ( final String header ) { if ( isExcluded ( header ) ) { return null ; } return super . getHeader ( header ) ; }


Input: { [CODESPLIT] @ Override public void put ( final K key , final V object , final long timeout ) { Objects . requireNonNull ( object ) ; final long stamp = lock . writeLock ( ) ; try { CacheObject < K , V > co = new CacheObject <> ( key , object , timeout ) ; if ( timeout != 0 ) { existCustomTimeout = true ; } if ( isReallyFull ( key ) ) { pruneCache ( ) ; } cacheMap . put ( key , co ) ; } finally { lock . unlockWrite ( stamp ) ; } }


Input: { [CODESPLIT] @ Override public V get ( final K key ) { long stamp = lock . readLock ( ) ; try { CacheObject < K , V > co = cacheMap . get ( key ) ; if ( co == null ) { missCount ++ ; return null ; } if ( co . isExpired ( ) ) { final long newStamp = lock . tryConvertToWriteLock ( stamp ) ; if ( newStamp != 0L ) { stamp = newStamp ; // lock is upgraded to write lock } else { // manually upgrade lock to write lock lock . unlockRead ( stamp ) ; stamp = lock . writeLock ( ) ; } CacheObject < K , V > removedCo = cacheMap . remove ( key ) ; if ( removedCo != null ) { onRemove ( removedCo . key , removedCo . cachedObject ) ; } missCount ++ ; return null ; } hitCount ++ ; return co . getObject ( ) ; } finally { lock . unlock ( stamp ) ; } }


Input: { [CODESPLIT] @ Override public V remove ( final K key ) { V removedValue = null ; final long stamp = lock . writeLock ( ) ; try { CacheObject < K , V > co = cacheMap . remove ( key ) ; if ( co != null ) { onRemove ( co . key , co . cachedObject ) ; removedValue = co . cachedObject ; } } finally { lock . unlockWrite ( stamp ) ; } return removedValue ; }


Input: { [CODESPLIT] @ Override public void clear ( ) { final long stamp = lock . writeLock ( ) ; try { cacheMap . clear ( ) ; } finally { lock . unlockWrite ( stamp ) ; } }


Input: { [CODESPLIT] @ Override public Map < K , V > snapshot ( ) { final long stamp = lock . writeLock ( ) ; try { Map < K , V > map = new HashMap <> ( cacheMap . size ( ) ) ; cacheMap . forEach ( ( key , cacheValue ) -> map . put ( key , cacheValue . getObject ( ) ) ) ; return map ; } finally { lock . unlockWrite ( stamp ) ; } }


Input: Configures Madvoc by reading context init parameters . [CODESPLIT] public void configureWith ( final ServletContext servletContext ) { webAppClassName = servletContext . getInitParameter ( PARAM_MADVOC_WEBAPP ) ; paramsFiles = Converter . get ( ) . toStringArray ( servletContext . getInitParameter ( PARAM_MADVOC_PARAMS ) ) ; madvocConfiguratorClassName = servletContext . getInitParameter ( PARAM_MADVOC_CONFIGURATOR ) ; }


Input: Creates and starts new <code > Madvoc< / code > web application . <code > Madvoc< / code > instance is stored in servlet context . Important : <code > servletContext< / code > may be <code > null< / code > when web application is run out from container . [CODESPLIT] @ SuppressWarnings ( "InstanceofCatchParameter" ) public WebApp startWebApplication ( final ServletContext servletContext ) { try { WebApp webApp = _start ( servletContext ) ; log . info ( "Madvoc is up and running." ) ; return webApp ; } catch ( Exception ex ) { if ( log != null ) { log . error ( "Madvoc startup failure." , ex ) ; } else { ex . printStackTrace ( ) ; } if ( ex instanceof MadvocException ) { throw ( MadvocException ) ex ; } throw new MadvocException ( ex ) ; } }


Input: Stops <em > Madvoc< / em > web application . [CODESPLIT] public void stopWebApplication ( ) { log . info ( "Madvoc shutting down..." ) ; if ( servletContext != null ) { servletContext . removeAttribute ( MADVOC_ATTR ) ; } webapp . shutdown ( ) ; webapp = null ; }


Input: Creates { [CODESPLIT] protected WebApp createWebApplication ( ) { if ( ( webAppClassName == null ) && ( webAppClass == null ) ) { return new WebApp ( ) ; } final WebApp webApp ; try { if ( webAppClassName != null ) { webAppClass = ClassLoaderUtil . loadClass ( webAppClassName ) ; } webApp = ( WebApp ) ClassUtil . newInstance ( webAppClass ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to load Madvoc web application class: " + webAppClassName , ex ) ; } return webApp ; }


Input: Loads Madvoc parameters . New { [CODESPLIT] protected Props loadMadvocParams ( final String [ ] patterns ) { if ( log . isInfoEnabled ( ) ) { log . info ( "Loading Madvoc parameters from: " + Converter . get ( ) . toString ( patterns ) ) ; } try { return new Props ( ) . loadFromClasspath ( patterns ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to load Madvoc parameters from: " + Converter . get ( ) . toString ( patterns ) + ".properties': " + ex . toString ( ) , ex ) ; } }


Input: Loads Madvoc component that will be used for configuring the user actions . If class name is <code > null< / code > default { [CODESPLIT] protected void resolveMadvocConfigClass ( ) { if ( ( madvocConfiguratorClassName == null ) && ( madvocConfiguratorClass == null ) ) { return ; } try { if ( madvocConfiguratorClassName != null ) { madvocConfiguratorClass = ClassLoaderUtil . loadClass ( madvocConfiguratorClassName ) ; } log . info ( "Configuring Madvoc using: " + madvocConfiguratorClass . getName ( ) ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to load Madvoc configurator class: " + madvocConfiguratorClassName , ex ) ; } }


Input: Defines a class from byte array into the specified class loader . Warning : this is a <b > hack< / b > ! [CODESPLIT] public static Class of ( final String className , final byte [ ] classData , ClassLoader classLoader ) { if ( classLoader == null ) { classLoader = ClassLoaderUtil . getDefaultClassLoader ( ) ; } try { final Method defineClassMethod = ClassLoader . class . getDeclaredMethod ( "defineClass" , String . class , byte [ ] . class , int . class , int . class ) ; defineClassMethod . setAccessible ( true ) ; return ( Class ) defineClassMethod . invoke ( classLoader , className , classData , 0 , classData . length ) ; } catch ( Throwable th ) { throw new RuntimeException ( "Define class failed: " + className , th ) ; } }


Input: Resets JSON parser so it can be reused . [CODESPLIT] protected void reset ( ) { this . ndx = 0 ; this . textLen = 0 ; this . path = new Path ( ) ; this . notFirstObject = false ; if ( useAltPaths ) { path . altPath = new Path ( ) ; } if ( classMetadataName != null ) { mapToBean = createMapToBean ( classMetadataName ) ; } }


Input: Defines how JSON parser works . In non - lazy mode the whole JSON is parsed as it is . In the lazy mode not everything is parsed but some things are left lazy . This way we gain performance especially on partial usage of the whole JSON . However be aware that parser holds the input memory until the returned objects are disposed . [CODESPLIT] public JsonParser lazy ( final boolean lazy ) { this . lazy = lazy ; this . mapSupplier = lazy ? LAZYMAP_SUPPLIER : HASHMAP_SUPPLIER ; this . listSupplier = lazy ? LAZYLIST_SUPPLIER : ARRAYLIST_SUPPLIER ; return this ; }


Input: Maps a class to given path . For arrays append <code > values< / code > to the path to specify component type ( if not specified by generics ) . [CODESPLIT] public JsonParser map ( final String path , final Class target ) { if ( path == null ) { rootType = target ; return this ; } if ( mappings == null ) { mappings = new HashMap <> ( ) ; } mappings . put ( Path . parse ( path ) , target ) ; return this ; }


Input: Replaces type with mapped type for current path . [CODESPLIT] protected Class replaceWithMappedTypeForPath ( final Class target ) { if ( mappings == null ) { return target ; } Class newType ; // first try alt paths Path altPath = path . getAltPath ( ) ; if ( altPath != null ) { if ( ! altPath . equals ( path ) ) { newType = mappings . get ( altPath ) ; if ( newType != null ) { return newType ; } } } // now check regular paths newType = mappings . get ( path ) ; if ( newType != null ) { return newType ; } return target ; }


Input: Defines { [CODESPLIT] public JsonParser withValueConverter ( final String path , final ValueConverter valueConverter ) { if ( convs == null ) { convs = new HashMap <> ( ) ; } convs . put ( Path . parse ( path ) , valueConverter ) ; return this ; }


Input: Adds a { [CODESPLIT] public JsonParser allowClass ( final String classPattern ) { if ( super . classnameWhitelist == null ) { super . classnameWhitelist = new ArrayList <> ( ) ; } classnameWhitelist . add ( classPattern ) ; return this ; }


Input: Parses input JSON as given type . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public < T > T parse ( final String input , final Class < T > targetType ) { rootType = targetType ; return _parse ( UnsafeUtil . getChars ( input ) ) ; }


Input: Parses input JSON to a list with specified component type . [CODESPLIT] public < T > List < T > parseAsList ( final String string , final Class < T > componentType ) { return new JsonParser ( ) . map ( JsonParser . VALUES , componentType ) . parse ( string ) ; }


Input: Parses input JSON to a list with specified key and value types . [CODESPLIT] public < K , V > Map < K , V > parseAsMap ( final String string , final Class < K > keyType , final Class < V > valueType ) { return new JsonParser ( ) . map ( JsonParser . KEYS , keyType ) . map ( JsonParser . VALUES , valueType ) . parse ( string ) ; }


Input: Parses input JSON as given type . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public < T > T parse ( final char [ ] input , final Class < T > targetType ) { rootType = targetType ; return _parse ( input ) ; }


Input: Parses a JSON value . [CODESPLIT] protected Object parseValue ( final Class targetType , final Class keyType , final Class componentType ) { final ValueConverter valueConverter ; final char c = input [ ndx ] ; switch ( c ) { case ' ' : if ( ! looseMode ) { break ; } case ' ' : ndx ++ ; Object string = parseStringContent ( c ) ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( string ) ; } if ( targetType != null && targetType != String . class ) { string = convertType ( string , targetType ) ; } return string ; case ' ' : ndx ++ ; if ( lazy ) { if ( notFirstObject ) { final Object value = new ObjectParser ( this , targetType , keyType , componentType ) ; skipObject ( ) ; return value ; } else { notFirstObject = true ; } } return parseObjectContent ( targetType , keyType , componentType ) ; case ' ' : ndx ++ ; return parseArrayContent ( targetType , componentType ) ; case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : Object number = parseNumber ( ) ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( number ) ; } if ( targetType != null ) { number = convertType ( number , targetType ) ; } return number ; case ' ' : ndx ++ ; if ( match ( N_ULL ) ) { valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( null ) ; } return null ; } break ; case ' ' : ndx ++ ; if ( match ( T_RUE ) ) { Object value = Boolean . TRUE ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( value ) ; } if ( targetType != null ) { value = convertType ( value , targetType ) ; } return value ; } break ; case ' ' : ndx ++ ; if ( match ( F_ALSE ) ) { Object value = Boolean . FALSE ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( value ) ; } if ( targetType != null ) { value = convertType ( value , targetType ) ; } return value ; } break ; } if ( looseMode ) { // try to parse unquoted string Object string = parseUnquotedStringContent ( ) ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( string ) ; } if ( targetType != null && targetType != String . class ) { string = convertType ( string , targetType ) ; } return string ; } syntaxError ( "Invalid char: " + input [ ndx ] ) ; return null ; }


Input: Resolves lazy value during the parsing runtime . [CODESPLIT] private Object resolveLazyValue ( Object value ) { if ( value instanceof Supplier ) { value = ( ( Supplier ) value ) . get ( ) ; } return value ; }


Input: Skips over complete object . It is not parsed just skipped . It will be parsed later but only if required . [CODESPLIT] private void skipObject ( ) { int bracketCount = 1 ; boolean insideString = false ; while ( ndx < total ) { final char c = input [ ndx ] ; if ( insideString ) { if ( c == ' ' && notPrecededByEvenNumberOfBackslashes ( ) ) { insideString = false ; } } else if ( c == ' ' ) { insideString = true ; } else if ( c == ' ' ) { bracketCount ++ ; } else if ( c == ' ' ) { bracketCount -- ; if ( bracketCount == 0 ) { ndx ++ ; return ; } } ndx ++ ; } }


Input: Parses a string . [CODESPLIT] protected String parseString ( ) { char quote = ' ' ; if ( looseMode ) { quote = consumeOneOf ( ' ' , ' ' ) ; if ( quote == 0 ) { return parseUnquotedStringContent ( ) ; } } else { consume ( quote ) ; } return parseStringContent ( quote ) ; }


Input: Parses string content once when starting quote has been consumed . [CODESPLIT] protected String parseStringContent ( final char quote ) { final int startNdx = ndx ; // roll-out until the end of the string or the escape char while ( true ) { final char c = input [ ndx ] ; if ( c == quote ) { // no escapes found, just use existing string ndx ++ ; return new String ( input , startNdx , ndx - 1 - startNdx ) ; } if ( c == ' ' ) { break ; } ndx ++ ; } // escapes found, proceed differently textLen = ndx - startNdx ; growEmpty ( ) ; //		for (int i = startNdx, j = 0; j < textLen; i++, j++) { //			text[j] = input[i]; //		} System . arraycopy ( input , startNdx , text , 0 , textLen ) ; // escape char, process everything until the end while ( true ) { char c = input [ ndx ] ; if ( c == quote ) { // done ndx ++ ; final String str = new String ( text , 0 , textLen ) ; textLen = 0 ; return str ; } if ( c == ' ' ) { // escape char found ndx ++ ; c = input [ ndx ] ; switch ( c ) { case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : ndx ++ ; c = parseUnicode ( ) ; break ; default : if ( looseMode ) { if ( c != ' ' ) { c = ' ' ; ndx -- ; } } else { syntaxError ( "Invalid escape char: " + c ) ; } } } text [ textLen ] = c ; textLen ++ ; growAndCopy ( ) ; ndx ++ ; } }


Input: Grows text array when { [CODESPLIT] protected void growAndCopy ( ) { if ( textLen == text . length ) { int newSize = text . length << 1 ; char [ ] newText = new char [ newSize ] ; if ( textLen > 0 ) { System . arraycopy ( text , 0 , newText , 0 , textLen ) ; } text = newText ; } }


Input: Parses 4 characters and returns unicode character . [CODESPLIT] protected char parseUnicode ( ) { int i0 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i1 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i2 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i3 = CharUtil . hex2int ( input [ ndx ] ) ; return ( char ) ( ( i0 << 12 ) + ( i1 << 8 ) + ( i2 << 4 ) + i3 ) ; }


Input: Parses un - quoted string content . [CODESPLIT] protected String parseUnquotedStringContent ( ) { final int startNdx = ndx ; while ( true ) { final char c = input [ ndx ] ; if ( c <= ' ' || CharUtil . equalsOne ( c , UNQUOTED_DELIMETERS ) ) { final int currentNdx = ndx ; // done skipWhiteSpaces ( ) ; return new String ( input , startNdx , currentNdx - startNdx ) ; } ndx ++ ; } }


Input: Parses JSON numbers . [CODESPLIT] protected Number parseNumber ( ) { final int startIndex = ndx ; char c = input [ ndx ] ; boolean isDouble = false ; boolean isExp = false ; if ( c == ' ' ) { ndx ++ ; } while ( true ) { if ( isEOF ( ) ) { break ; } c = input [ ndx ] ; if ( c >= ' ' && c <= ' ' ) { ndx ++ ; continue ; } if ( c <= 32 ) { // white space break ; } if ( c == ' ' || c == ' ' || c == ' ' ) { // delimiter break ; } if ( c == ' ' ) { isDouble = true ; } else if ( c == ' ' || c == ' ' ) { isExp = true ; } ndx ++ ; } final String value = new String ( input , startIndex , ndx - startIndex ) ; if ( isDouble ) { return Double . valueOf ( value ) ; } long longNumber ; if ( isExp ) { longNumber = Double . valueOf ( value ) . longValue ( ) ; } else { if ( value . length ( ) >= 19 ) { // if string is 19 chars and longer, it can be over the limit BigInteger bigInteger = new BigInteger ( value ) ; if ( isGreaterThanLong ( bigInteger ) ) { return bigInteger ; } longNumber = bigInteger . longValue ( ) ; } else { longNumber = Long . parseLong ( value ) ; } } if ( ( longNumber >= Integer . MIN_VALUE ) && ( longNumber <= Integer . MAX_VALUE ) ) { return ( int ) longNumber ; } return longNumber ; }


Input: Parses arrays once when open bracket has been consumed . [CODESPLIT] protected Object parseArrayContent ( Class targetType , Class componentType ) { // detect special case if ( targetType == Object . class ) { targetType = List . class ; } // continue targetType = replaceWithMappedTypeForPath ( targetType ) ; if ( componentType == null && targetType != null && targetType . isArray ( ) ) { componentType = targetType . getComponentType ( ) ; } path . push ( VALUES ) ; componentType = replaceWithMappedTypeForPath ( componentType ) ; Collection < Object > target = newArrayInstance ( targetType ) ; boolean koma = false ; mainloop : while ( true ) { skipWhiteSpaces ( ) ; char c = input [ ndx ] ; if ( c == ' ' ) { if ( koma ) { syntaxError ( "Trailing comma" ) ; } ndx ++ ; path . pop ( ) ; return target ; } Object value = parseValue ( componentType , null , null ) ; target . add ( value ) ; skipWhiteSpaces ( ) ; c = input [ ndx ] ; switch ( c ) { case ' ' : ndx ++ ; break mainloop ; case ' ' : ndx ++ ; koma = true ; break ; default : syntaxError ( "Invalid char: expected ] or ," ) ; } } path . pop ( ) ; if ( targetType != null ) { return convertType ( target , targetType ) ; } return target ; }


Input: Parses object once when open bracket has been consumed . [CODESPLIT] protected Object parseObjectContent ( Class targetType , Class valueKeyType , Class valueType ) { // detect special case if ( targetType == Object . class ) { targetType = Map . class ; } // continue targetType = replaceWithMappedTypeForPath ( targetType ) ; Object target ; boolean isTargetTypeMap = true ; boolean isTargetRealTypeMap = true ; ClassDescriptor targetTypeClassDescriptor = null ; TypeData typeData = null ; if ( targetType != null ) { targetTypeClassDescriptor = ClassIntrospector . get ( ) . lookup ( targetType ) ; // find if the target is really a map // because when classMetadataName != null we are forcing // map usage locally in this method isTargetRealTypeMap = targetTypeClassDescriptor . isMap ( ) ; typeData = jsonAnnotationManager . lookupTypeData ( targetType ) ; } if ( isTargetRealTypeMap ) { // resolve keys only for real maps path . push ( KEYS ) ; valueKeyType = replaceWithMappedTypeForPath ( valueKeyType ) ; path . pop ( ) ; } if ( classMetadataName == null ) { // create instance of target type, no 'class' information target = newObjectInstance ( targetType ) ; isTargetTypeMap = isTargetRealTypeMap ; } else { // all beans will be created first as a map target = mapSupplier . get ( ) ; } boolean koma = false ; mainloop : while ( true ) { skipWhiteSpaces ( ) ; char c = input [ ndx ] ; if ( c == ' ' ) { if ( koma ) { syntaxError ( "Trailing comma" ) ; } ndx ++ ; break ; } koma = false ; String key = parseString ( ) ; String keyOriginal = key ; skipWhiteSpaces ( ) ; consume ( ' ' ) ; skipWhiteSpaces ( ) ; // read the type of the simple property PropertyDescriptor pd = null ; Class propertyType = null ; Class keyType = null ; Class componentType = null ; // resolve simple property if ( ! isTargetRealTypeMap ) { // replace key with real property value key = jsonAnnotationManager . resolveRealName ( targetType , key ) ; } if ( ! isTargetTypeMap ) { pd = targetTypeClassDescriptor . getPropertyDescriptor ( key , true ) ; if ( pd != null ) { propertyType = pd . getType ( ) ; keyType = pd . resolveKeyType ( true ) ; componentType = pd . resolveComponentType ( true ) ; } } Object value ; if ( ! isTargetTypeMap ) { // *** inject into bean path . push ( key ) ; value = parseValue ( propertyType , keyType , componentType ) ; path . pop ( ) ; if ( typeData . rules . match ( keyOriginal , ! typeData . strict ) ) { if ( pd != null ) { if ( lazy ) { // need to resolve lazy value before injecting objects into it value = resolveLazyValue ( value ) ; } // only inject values if target property exist injectValueIntoObject ( target , pd , value ) ; } } } else { Object keyValue = key ; if ( valueKeyType != null ) { keyValue = convertType ( key , valueKeyType ) ; } // *** add to map if ( isTargetRealTypeMap ) { path . push ( VALUES , key ) ; valueType = replaceWithMappedTypeForPath ( valueType ) ; } else { path . push ( key ) ; } value = parseValue ( valueType , null , null ) ; path . pop ( ) ; ( ( Map ) target ) . put ( keyValue , value ) ; } skipWhiteSpaces ( ) ; c = input [ ndx ] ; switch ( c ) { case ' ' : ndx ++ ; break mainloop ; case ' ' : ndx ++ ; koma = true ; break ; default : syntaxError ( "Invalid char: expected } or ," ) ; } } // done // convert Map to target type if ( classMetadataName != null ) { target = mapToBean . map2bean ( ( Map ) target , targetType ) ; } return target ; }


Input: Consumes one of the allowed char at current position . If char is different return <code > 0< / code > . If matched returns matched char . [CODESPLIT] protected char consumeOneOf ( final char c1 , final char c2 ) { char c = input [ ndx ] ; if ( ( c != c1 ) && ( c != c2 ) ) { return 0 ; } ndx ++ ; return c ; }


Input: Matches char buffer with content on given location . [CODESPLIT] protected final boolean match ( final char [ ] target ) { for ( char c : target ) { if ( input [ ndx ] != c ) { return false ; } ndx ++ ; } return true ; }


Input: Throws { [CODESPLIT] protected void syntaxError ( final String message ) { String left = "..." ; String right = "..." ; int offset = 10 ; int from = ndx - offset ; if ( from < 0 ) { from = 0 ; left = StringPool . EMPTY ; } int to = ndx + offset ; if ( to > input . length ) { to = input . length ; right = StringPool . EMPTY ; } final CharSequence str = CharArraySequence . of ( input , from , to - from ) ; throw new JsonException ( "Syntax error! " + message + "\n" + "offset: " + ndx + " near: \"" + left + str + right + "\"" ) ; }


Input: { [CODESPLIT] @ Override public void visit ( final int version , int access , final String name , final String signature , final String superName , String [ ] interfaces ) { wd . init ( name , superName , this . suffix , this . reqProxyClassName ) ; // no superclass wd . superName = AsmUtil . SIGNATURE_JAVA_LANG_OBJECT ; // change access of destination access &= ~ AsmUtil . ACC_ABSTRACT ; access &= ~ AsmUtil . ACC_INTERFACE ; // write destination class if ( targetClassOrInterface . isInterface ( ) ) { // target is interface wd . wrapInterface = true ; interfaces = new String [ ] { targetClassOrInterface . getName ( ) . replace ( ' ' , ' ' ) } ; } else { // target is class wd . wrapInterface = false ; if ( targetInterface != null ) { // interface provided interfaces = new String [ ] { targetInterface . getName ( ) . replace ( ' ' , ' ' ) } ; } else { // no interface provided, use all //interfaces = null; } } final int v = ProxettaAsmUtil . resolveJavaVersion ( version ) ; wd . dest . visit ( v , access , wd . thisReference , signature , wd . superName , interfaces ) ; wd . proxyAspects = new ProxyAspectData [ aspects . length ] ; for ( int i = 0 ; i < aspects . length ; i ++ ) { wd . proxyAspects [ i ] = new ProxyAspectData ( wd , aspects [ i ] , i ) ; } // create new field wrapper field and store it's reference into work-data wd . wrapperRef = targetFieldName ; wd . wrapperType = ' ' + name + ' ' ; if ( createTargetInDefaultCtor ) { // create private, final field final FieldVisitor fv = wd . dest . visitField ( AsmUtil . ACC_PRIVATE | AsmUtil . ACC_FINAL , wd . wrapperRef , wd . wrapperType , null , null ) ; fv . visitEnd ( ) ; createEmptyCtorThatCreatesTarget ( ) ; } else { // create public, non-final field final FieldVisitor fv = wd . dest . visitField ( AsmUtil . ACC_PUBLIC , wd . wrapperRef , wd . wrapperType , null , null ) ; fv . visitEnd ( ) ; createEmptyCtor ( ) ; } }


Input: Created empty default constructor . [CODESPLIT] protected void createEmptyCtor ( ) { final MethodVisitor mv = wd . dest . visitMethod ( AsmUtil . ACC_PUBLIC , INIT , "()V" , null , null ) ; mv . visitCode ( ) ; mv . visitVarInsn ( Opcodes . ALOAD , 0 ) ; mv . visitMethodInsn ( Opcodes . INVOKESPECIAL , AsmUtil . SIGNATURE_JAVA_LANG_OBJECT , INIT , "()V" , false ) ; mv . visitInsn ( Opcodes . RETURN ) ; mv . visitMaxs ( 1 , 1 ) ; mv . visitEnd ( ) ; }


Input: { [CODESPLIT] @ Override public MethodVisitor visitMethod ( final int access , final String name , final String desc , final String signature , final String [ ] exceptions ) { MethodSignatureVisitor msign = targetClassInfo . lookupMethodSignatureVisitor ( access , name , desc , wd . superReference ) ; if ( msign == null ) { return null ; } // ignore all destination constructors if ( name . equals ( INIT ) ) { return null ; } // ignore all destination static block if ( name . equals ( CLINIT ) ) { return null ; } // skip all static methods if ( Modifier . isStatic ( access ) ) { return null ; } return applyProxy ( msign ) ; }


Input: Creates simple method wrapper without proxy . [CODESPLIT] protected void createSimpleMethodWrapper ( final MethodSignatureVisitor msign ) { int access = msign . getAccessFlags ( ) ; access &= ~ ACC_ABSTRACT ; access &= ~ ACC_NATIVE ; MethodVisitor mv = wd . dest . visitMethod ( access , msign . getMethodName ( ) , msign . getDescription ( ) , msign . getAsmMethodSignature ( ) , msign . getExceptions ( ) ) ; mv . visitCode ( ) ; mv . visitVarInsn ( ALOAD , 0 ) ; mv . visitFieldInsn ( GETFIELD , wd . thisReference , wd . wrapperRef , wd . wrapperType ) ; loadVirtualMethodArguments ( mv , msign ) ; if ( wd . wrapInterface ) { mv . visitMethodInsn ( INVOKEINTERFACE , wd . wrapperType . substring ( 1 , wd . wrapperType . length ( ) - 1 ) , msign . getMethodName ( ) , msign . getDescription ( ) , true ) ; } else { mv . visitMethodInsn ( INVOKEVIRTUAL , wd . wrapperType . substring ( 1 , wd . wrapperType . length ( ) - 1 ) , msign . getMethodName ( ) , msign . getDescription ( ) , false ) ; } ProxettaAsmUtil . prepareReturnValue ( mv , msign , 0 ) ; visitReturn ( mv , msign , true ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; }


Input: ---------------------------------------------------------------- method - info signature [CODESPLIT] @ Override public String getSignature ( ) { if ( signature == null ) { String decl = getDeclaration ( ) ; int ndx = decl . indexOf ( ' ' ) ; ndx ++ ; String retType = decl . substring ( ndx ) ; StringBuilder methodDeclaration = new StringBuilder ( 50 ) ; methodDeclaration . append ( retType ) . append ( ' ' ) . append ( methodName ) . append ( decl , 0 , ndx ) ; String exceptionsAsString = getExceptionsAsString ( ) ; if ( exceptionsAsString != null ) { methodDeclaration . append ( " throws " ) . append ( exceptionsAsString ) ; } signature = methodDeclaration . toString ( ) ; } return signature ; }


Input: Resolves raw type name using the generics information from the class or method information . [CODESPLIT] private String resolveRawTypeName ( String typeName ) { if ( typeName == null ) { return null ; } boolean isArray = typeName . startsWith ( StringPool . LEFT_SQ_BRACKET ) ; if ( isArray ) { typeName = typeName . substring ( 1 ) ; } String rawTypeName ; if ( generics . containsKey ( typeName ) ) { rawTypeName = generics . get ( typeName ) ; } else { rawTypeName = declaredTypeGeneric . getOrDefault ( typeName , typeName ) ; } if ( isArray ) { rawTypeName = ' ' + rawTypeName ; } return rawTypeName ; }


Input: Resolves reference from given values . Returns bean reference of given value or defaults if given name is blank . [CODESPLIT] public BeanReferences resolveReferenceFromValue ( final PropertyDescriptor propertyDescriptor , final String refName ) { BeanReferences references ; if ( refName == null || refName . isEmpty ( ) ) { references = buildDefaultReference ( propertyDescriptor ) ; } else { references = BeanReferences . of ( refName ) ; } references = references . removeDuplicateNames ( ) ; return references ; }


Input: Takes given parameters references and returns reference set for given method or constructor . [CODESPLIT] public BeanReferences [ ] resolveReferenceFromValues ( final Executable methodOrCtor , final String ... parameterReferences ) { BeanReferences [ ] references = convertRefToReferences ( parameterReferences ) ; if ( references == null || references . length == 0 ) { references = buildDefaultReferences ( methodOrCtor ) ; } if ( methodOrCtor . getParameterTypes ( ) . length != references . length ) { throw new PetiteException ( "Different number of method parameters and references for: " + methodOrCtor . getDeclaringClass ( ) . getName ( ) + ' ' + methodOrCtor . getName ( ) ) ; } removeAllDuplicateNames ( references ) ; return references ; }


Input: Extracts references for given property . Returns { [CODESPLIT] public BeanReferences readReferenceFromAnnotation ( final PropertyDescriptor propertyDescriptor ) { final MethodDescriptor writeMethodDescriptor = propertyDescriptor . getWriteMethodDescriptor ( ) ; final FieldDescriptor fieldDescriptor = propertyDescriptor . getFieldDescriptor ( ) ; PetiteInject ref = null ; if ( writeMethodDescriptor != null ) { ref = writeMethodDescriptor . getMethod ( ) . getAnnotation ( PetiteInject . class ) ; } if ( ref == null && fieldDescriptor != null ) { ref = fieldDescriptor . getField ( ) . getAnnotation ( PetiteInject . class ) ; } if ( ref == null ) { return null ; } BeanReferences reference = null ; String name = ref . value ( ) . trim ( ) ; if ( name . length ( ) != 0 ) { reference = BeanReferences . of ( name ) ; } reference = updateReferencesWithDefaultsIfNeeded ( propertyDescriptor , reference ) ; reference = reference . removeDuplicateNames ( ) ; return reference ; }


Input: Extracts references from method or constructor annotation . [CODESPLIT] public BeanReferences [ ] readAllReferencesFromAnnotation ( final Executable methodOrCtor ) { PetiteInject petiteInject = methodOrCtor . getAnnotation ( PetiteInject . class ) ; final Parameter [ ] parameters = methodOrCtor . getParameters ( ) ; BeanReferences [ ] references ; final boolean hasAnnotationOnMethodOrCtor ; if ( petiteInject != null ) { references = convertAnnValueToReferences ( petiteInject . value ( ) ) ; hasAnnotationOnMethodOrCtor = true ; } else { references = new BeanReferences [ parameters . length ] ; hasAnnotationOnMethodOrCtor = false ; } int parametersWithAnnotationCount = 0 ; for ( int i = 0 ; i < parameters . length ; i ++ ) { Parameter parameter = parameters [ i ] ; petiteInject = parameter . getAnnotation ( PetiteInject . class ) ; if ( petiteInject == null ) { // no annotation on argument continue ; } // there is annotation on argument, override values String annotationValue = readAnnotationValue ( petiteInject ) ; if ( annotationValue != null ) { references [ i ] = BeanReferences . of ( annotationValue ) ; } parametersWithAnnotationCount ++ ; } if ( ! hasAnnotationOnMethodOrCtor ) { if ( parametersWithAnnotationCount == 0 ) { return null ; } if ( parametersWithAnnotationCount != parameters . length ) { throw new PetiteException ( "All arguments must be annotated with PetiteInject" ) ; } } references = updateReferencesWithDefaultsIfNeeded ( methodOrCtor , references ) ; removeAllDuplicateNames ( references ) ; return references ; }


Input: Reads annotation value and returns { [CODESPLIT] private String readAnnotationValue ( final PetiteInject annotation ) { String value = annotation . value ( ) . trim ( ) ; if ( value . isEmpty ( ) ) { return null ; } return value ; }


Input: Builds default method references . [CODESPLIT] private BeanReferences [ ] buildDefaultReferences ( final Executable methodOrCtor ) { final boolean useParamo = petiteConfig . getUseParamo ( ) ; final PetiteReferenceType [ ] lookupReferences = petiteConfig . getLookupReferences ( ) ; MethodParameter [ ] methodParameters = null ; if ( useParamo ) { methodParameters = Paramo . resolveParameters ( methodOrCtor ) ; } final Class [ ] paramTypes = methodOrCtor . getParameterTypes ( ) ; final BeanReferences [ ] references = new BeanReferences [ paramTypes . length ] ; for ( int j = 0 ; j < paramTypes . length ; j ++ ) { String [ ] ref = new String [ lookupReferences . length ] ; references [ j ] = BeanReferences . of ( ref ) ; for ( int i = 0 ; i < ref . length ; i ++ ) { switch ( lookupReferences [ i ] ) { case NAME : ref [ i ] = methodParameters != null ? methodParameters [ j ] . getName ( ) : null ; break ; case TYPE_SHORT_NAME : ref [ i ] = StringUtil . uncapitalize ( paramTypes [ j ] . getSimpleName ( ) ) ; break ; case TYPE_FULL_NAME : ref [ i ] = paramTypes [ j ] . getName ( ) ; break ; } } } return references ; }


Input: Builds default field references . [CODESPLIT] public BeanReferences buildDefaultReference ( final PropertyDescriptor propertyDescriptor ) { final PetiteReferenceType [ ] lookupReferences = petiteConfig . getLookupReferences ( ) ; final String [ ] references = new String [ lookupReferences . length ] ; for ( int i = 0 ; i < references . length ; i ++ ) { switch ( lookupReferences [ i ] ) { case NAME : references [ i ] = propertyDescriptor . getName ( ) ; break ; case TYPE_SHORT_NAME : references [ i ] = StringUtil . uncapitalize ( propertyDescriptor . getType ( ) . getSimpleName ( ) ) ; break ; case TYPE_FULL_NAME : references [ i ] = propertyDescriptor . getType ( ) . getName ( ) ; break ; } } return BeanReferences . of ( references ) ; }


Input: Removes duplicate names from bean references . [CODESPLIT] private void removeAllDuplicateNames ( final BeanReferences [ ] allBeanReferences ) { for ( int i = 0 ; i < allBeanReferences . length ; i ++ ) { BeanReferences references = allBeanReferences [ i ] ; allBeanReferences [ i ] = references . removeDuplicateNames ( ) ; } }


Input: Converts single string array to an array of bean references . [CODESPLIT] private BeanReferences [ ] convertRefToReferences ( final String [ ] references ) { if ( references == null ) { return null ; } BeanReferences [ ] ref = new BeanReferences [ references . length ] ; for ( int i = 0 ; i < references . length ; i ++ ) { ref [ i ] = BeanReferences . of ( references [ i ] ) ; } return ref ; }


Input: Converts comma - separated string into array of Bean references . [CODESPLIT] private BeanReferences [ ] convertAnnValueToReferences ( String value ) { if ( value == null ) { return null ; } value = value . trim ( ) ; if ( value . length ( ) == 0 ) { return null ; } String [ ] refNames = Converter . get ( ) . toStringArray ( value ) ; BeanReferences [ ] references = new BeanReferences [ refNames . length ] ; for ( int i = 0 ; i < refNames . length ; i ++ ) { references [ i ] = BeanReferences . of ( refNames [ i ] . trim ( ) ) ; } return references ; }


Input: Runs JOY in standalone mode with only backend . [CODESPLIT] public void runJoy ( final Consumer < JoddJoyRuntime > consumer ) { final JoddJoy joddJoy = new JoddJoy ( ) ; final JoddJoyRuntime joyRuntime = joddJoy . startOnlyBackend ( ) ; joddJoy . withDb ( joyDb -> setJtxManager ( joyRuntime . getJtxManager ( ) ) ) ; final JtxTransaction tx = startRwTx ( ) ; final Print print = new Print ( ) ; try { print . line ( "START" , 80 ) ; print . newLine ( ) ; consumer . accept ( joyRuntime ) ; print . newLine ( ) ; print . line ( "END" , 80 ) ; if ( tx != null ) { tx . commit ( ) ; } } catch ( Throwable throwable ) { throwable . printStackTrace ( ) ; if ( tx != null ) { tx . rollback ( ) ; } } joddJoy . stop ( ) ; }


Input: Starts new read / write transaction in PROPAGATION_REQUIRED mode . [CODESPLIT] private JtxTransaction startRwTx ( ) { if ( jtxManager == null ) { return null ; } return jtxManager . requestTransaction ( new JtxTransactionMode ( JtxPropagationBehavior . PROPAGATION_REQUIRED , false ) ) ; }


Input: Returns method from an object matched by name . This may be considered as a slow operation since methods are matched one by one . Returns only accessible methods . Only first method is matched . [CODESPLIT] public static Method findMethod ( final Class c , final String methodName ) { return findDeclaredMethod ( c , methodName , true ) ; }


Input: Finds constructor with given parameter types . First matched ctor is returned . [CODESPLIT] public static < T > Constructor < T > findConstructor ( final Class < T > clazz , final Class < ? > ... parameterTypes ) { final Constructor < ? > [ ] constructors = clazz . getConstructors ( ) ; Class < ? > [ ] pts ; for ( Constructor < ? > constructor : constructors ) { pts = constructor . getParameterTypes ( ) ; if ( isAllAssignableFrom ( pts , parameterTypes ) ) { return ( Constructor < T > ) constructor ; } } return null ; }


Input: Returns { [CODESPLIT] public static boolean isAllAssignableFrom ( final Class < ? > [ ] typesTarget , final Class < ? > [ ] typesFrom ) { if ( typesTarget . length == typesFrom . length ) { for ( int i = 0 ; i < typesTarget . length ; i ++ ) { if ( ! typesTarget [ i ] . isAssignableFrom ( typesFrom [ i ] ) ) { return false ; } } return true ; } return false ; }


Input: Returns classes from array of objects . It accepts { [CODESPLIT] public static Class [ ] getClasses ( final Object ... objects ) { if ( objects . length == 0 ) { return EMPTY_CLASS_ARRAY ; } Class [ ] result = new Class [ objects . length ] ; for ( int i = 0 ; i < objects . length ; i ++ ) { if ( objects [ i ] != null ) { result [ i ] = objects [ i ] . getClass ( ) ; } } return result ; }


Input: Safe version of <code > isAssignableFrom< / code > method that returns <code > false< / code > if one of the arguments is <code > null< / code > . [CODESPLIT] public static boolean isTypeOf ( final Class < ? > lookupClass , final Class < ? > targetClass ) { if ( targetClass == null || lookupClass == null ) { return false ; } return targetClass . isAssignableFrom ( lookupClass ) ; }


Input: Safe version of <code > isInstance< / code > returns <code > false< / code > if any of the arguments is <code > null< / code > . [CODESPLIT] public static boolean isInstanceOf ( final Object object , final Class target ) { if ( object == null || target == null ) { return false ; } return target . isInstance ( object ) ; }


Input: Resolves all interfaces of a type . No duplicates are returned . Direct interfaces are prior the interfaces of subclasses in the returned array . [CODESPLIT] public static Class [ ] resolveAllInterfaces ( final Class type ) { Set < Class > bag = new LinkedHashSet <> ( ) ; _resolveAllInterfaces ( type , bag ) ; return bag . toArray ( new Class [ 0 ] ) ; }


Input: Resolves all super classes from top ( direct subclass ) to down . <code > Object< / code > class is not included in the list . [CODESPLIT] public static Class [ ] resolveAllSuperclasses ( Class type ) { List < Class > list = new ArrayList <> ( ) ; while ( true ) { type = type . getSuperclass ( ) ; if ( ( type == null ) || ( type == Object . class ) ) { break ; } list . add ( type ) ; } return list . toArray ( new Class [ 0 ] ) ; }


Input: Returns array of all methods that are accessible from given class upto limit ( usually <code > Object . class< / code > ) . Abstract methods are ignored . [CODESPLIT] public static Method [ ] getAccessibleMethods ( Class clazz , final Class limit ) { Package topPackage = clazz . getPackage ( ) ; List < Method > methodList = new ArrayList <> ( ) ; int topPackageHash = topPackage == null ? 0 : topPackage . hashCode ( ) ; boolean top = true ; do { if ( clazz == null ) { break ; } Method [ ] declaredMethods = clazz . getDeclaredMethods ( ) ; for ( Method method : declaredMethods ) { if ( Modifier . isVolatile ( method . getModifiers ( ) ) ) { continue ; } //				if (Modifier.isAbstract(method.getModifiers())) { //					continue; //				} if ( top ) { // add all top declared methods methodList . add ( method ) ; continue ; } int modifier = method . getModifiers ( ) ; if ( Modifier . isPrivate ( modifier ) ) { continue ; // ignore super private methods } if ( Modifier . isAbstract ( modifier ) ) { // ignore super abstract methods continue ; } if ( Modifier . isPublic ( modifier ) ) { addMethodIfNotExist ( methodList , method ) ; // add super public methods continue ; } if ( Modifier . isProtected ( modifier ) ) { addMethodIfNotExist ( methodList , method ) ; // add super protected methods continue ; } // add super default methods from the same package Package pckg = method . getDeclaringClass ( ) . getPackage ( ) ; int pckgHash = pckg == null ? 0 : pckg . hashCode ( ) ; if ( pckgHash == topPackageHash ) { addMethodIfNotExist ( methodList , method ) ; } } top = false ; } while ( ( clazz = clazz . getSuperclass ( ) ) != limit ) ; Method [ ] methods = new Method [ methodList . size ( ) ] ; for ( int i = 0 ; i < methods . length ; i ++ ) { methods [ i ] = methodList . get ( i ) ; } return methods ; }


Input: Returns a <code > Method< / code > array of the methods to which instances of the specified respond except for those methods defined in the class specified by limit or any of its superclasses . Note that limit is usually used to eliminate them methods defined by <code > java . lang . Object< / code > . If limit is <code > null< / code > then all methods are returned . [CODESPLIT] public static Method [ ] getSupportedMethods ( final Class clazz , final Class limit ) { final ArrayList < Method > supportedMethods = new ArrayList <> ( ) ; for ( Class c = clazz ; c != limit && c != null ; c = c . getSuperclass ( ) ) { final Method [ ] methods = c . getDeclaredMethods ( ) ; for ( final Method method : methods ) { boolean found = false ; for ( final Method supportedMethod : supportedMethods ) { if ( compareSignatures ( method , supportedMethod ) ) { found = true ; break ; } } if ( ! found ) { supportedMethods . add ( method ) ; } } } return supportedMethods . toArray ( new Method [ 0 ] ) ; }


Input: Compares method declarations : signature and return types . [CODESPLIT] public static boolean compareDeclarations ( final Method first , final Method second ) { if ( first . getReturnType ( ) != second . getReturnType ( ) ) { return false ; } return compareSignatures ( first , second ) ; }


Input: Compares method signatures : names and parameters . [CODESPLIT] public static boolean compareSignatures ( final Method first , final Method second ) { if ( ! first . getName ( ) . equals ( second . getName ( ) ) ) { return false ; } return compareParameters ( first . getParameterTypes ( ) , second . getParameterTypes ( ) ) ; }


Input: Compares classes usually method or ctor parameters . [CODESPLIT] public static boolean compareParameters ( final Class [ ] first , final Class [ ] second ) { if ( first . length != second . length ) { return false ; } for ( int i = 0 ; i < first . length ; i ++ ) { if ( first [ i ] != second [ i ] ) { return false ; } } return true ; }


Input: Suppress access check against a reflection object . SecurityException is silently ignored . Checks first if the object is already accessible . [CODESPLIT] public static void forceAccess ( final AccessibleObject accObject ) { try { if ( System . getSecurityManager ( ) == null ) accObject . setAccessible ( true ) ; else { AccessController . doPrivileged ( ( PrivilegedAction ) ( ) -> { accObject . setAccessible ( true ) ; return null ; } ) ; } } catch ( SecurityException sex ) { // ignore } }


Input: Returns <code > true< / code > if class member is public and if its declaring class is also public . [CODESPLIT] public static boolean isPublicPublic ( final Member member ) { if ( Modifier . isPublic ( member . getModifiers ( ) ) ) { if ( Modifier . isPublic ( member . getDeclaringClass ( ) . getModifiers ( ) ) ) { return true ; } } return false ; }


Input: Creates new instance of given class with given optional arguments . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static < T > T newInstance ( final Class < T > clazz , final Object ... params ) throws InstantiationException , IllegalAccessException , InvocationTargetException , NoSuchMethodException { if ( params . length == 0 ) { return newInstance ( clazz ) ; } final Class < ? > [ ] paramTypes = getClasses ( params ) ; final Constructor < ? > constructor = findConstructor ( clazz , paramTypes ) ; if ( constructor == null ) { throw new InstantiationException ( "No constructor matched parameter types." ) ; } return ( T ) constructor . newInstance ( params ) ; }


Input: Creates new instances including for common mutable classes that do not have a default constructor . more user - friendly . It examines if class is a map list String Character Boolean or a Number . Immutable instances are cached and not created again . Arrays are also created with no elements . Note that this bunch of <code > if< / code > blocks is faster then using a <code > HashMap< / code > . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static < T > T newInstance ( final Class < T > type ) throws IllegalAccessException , InstantiationException , NoSuchMethodException , InvocationTargetException { if ( type . isPrimitive ( ) ) { if ( type == int . class ) { return ( T ) Integer . valueOf ( 0 ) ; } if ( type == long . class ) { return ( T ) Long . valueOf ( 0 ) ; } if ( type == boolean . class ) { return ( T ) Boolean . FALSE ; } if ( type == float . class ) { return ( T ) Float . valueOf ( 0 ) ; } if ( type == double . class ) { return ( T ) Double . valueOf ( 0 ) ; } if ( type == byte . class ) { return ( T ) Byte . valueOf ( ( byte ) 0 ) ; } if ( type == short . class ) { return ( T ) Short . valueOf ( ( short ) 0 ) ; } if ( type == char . class ) { return ( T ) Character . valueOf ( ( char ) 0 ) ; } throw new IllegalArgumentException ( "Invalid primitive: " + type ) ; } if ( type . getName ( ) . startsWith ( "java." ) ) { if ( type == Integer . class ) { return ( T ) Integer . valueOf ( 0 ) ; } if ( type == String . class ) { return ( T ) StringPool . EMPTY ; } if ( type == Long . class ) { return ( T ) Long . valueOf ( 0 ) ; } if ( type == Boolean . class ) { return ( T ) Boolean . FALSE ; } if ( type == Float . class ) { return ( T ) Float . valueOf ( 0 ) ; } if ( type == Double . class ) { return ( T ) Double . valueOf ( 0 ) ; } if ( type == Map . class ) { return ( T ) new HashMap ( ) ; } if ( type == List . class ) { return ( T ) new ArrayList ( ) ; } if ( type == Set . class ) { return ( T ) new HashSet ( ) ; } if ( type == Collection . class ) { return ( T ) new ArrayList ( ) ; } if ( type == Byte . class ) { return ( T ) Byte . valueOf ( ( byte ) 0 ) ; } if ( type == Short . class ) { return ( T ) Short . valueOf ( ( short ) 0 ) ; } if ( type == Character . class ) { return ( T ) Character . valueOf ( ( char ) 0 ) ; } } if ( type . isEnum ( ) ) { return type . getEnumConstants ( ) [ 0 ] ; } if ( type . isArray ( ) ) { return ( T ) Array . newInstance ( type . getComponentType ( ) , 0 ) ; } Constructor < T > declaredConstructor = type . getDeclaredConstructor ( ) ; forceAccess ( declaredConstructor ) ; return declaredConstructor . newInstance ( ) ; }


Input: Returns <code > true< / code > if the first member is accessible from second one . [CODESPLIT] public static boolean isAssignableFrom ( final Member member1 , final Member member2 ) { return member1 . getDeclaringClass ( ) . isAssignableFrom ( member2 . getDeclaringClass ( ) ) ; }


Input: Returns all superclasses . [CODESPLIT] public static Class [ ] getSuperclasses ( final Class type ) { int i = 0 ; for ( Class x = type . getSuperclass ( ) ; x != null ; x = x . getSuperclass ( ) ) { i ++ ; } Class [ ] result = new Class [ i ] ; i = 0 ; for ( Class x = type . getSuperclass ( ) ; x != null ; x = x . getSuperclass ( ) ) { result [ i ] = x ; i ++ ; } return result ; }


Input: Returns <code > true< / code > if method is a bean property . [CODESPLIT] public static boolean isBeanProperty ( final Method method ) { if ( isObjectMethod ( method ) ) { return false ; } String methodName = method . getName ( ) ; Class returnType = method . getReturnType ( ) ; Class [ ] paramTypes = method . getParameterTypes ( ) ; if ( methodName . startsWith ( METHOD_GET_PREFIX ) ) { // getter method must starts with 'get' and it is not getClass() if ( ( returnType != null ) && ( paramTypes . length == 0 ) ) { // getter must have a return type and no arguments return true ; } } else if ( methodName . startsWith ( METHOD_IS_PREFIX ) ) { // ister must starts with 'is' if ( ( returnType != null ) && ( paramTypes . length == 0 ) ) { // ister must have return type and no arguments return true ; } } else if ( methodName . startsWith ( METHOD_SET_PREFIX ) ) { // setter must start with a 'set' if ( paramTypes . length == 1 ) { // setter must have just one argument return true ; } } return false ; }


Input: Returns property name from a getter method . Returns <code > null< / code > if method is not a real getter . [CODESPLIT] public static String getBeanPropertyGetterName ( final Method method ) { int prefixLength = getBeanPropertyGetterPrefixLength ( method ) ; if ( prefixLength == 0 ) { return null ; } String methodName = method . getName ( ) . substring ( prefixLength ) ; return StringUtil . decapitalize ( methodName ) ; }


Input: Returns beans property setter name or <code > null< / code > if method is not a real setter . [CODESPLIT] public static String getBeanPropertySetterName ( final Method method ) { int prefixLength = getBeanPropertySetterPrefixLength ( method ) ; if ( prefixLength == 0 ) { return null ; } String methodName = method . getName ( ) . substring ( prefixLength ) ; return StringUtil . decapitalize ( methodName ) ; }


Input: Returns single component type for given type and implementation . Index is used when type consist of many components . If negative index will be calculated from the end of the returned array . Returns <code > null< / code > if component type does not exist or if index is out of bounds . <p > [CODESPLIT] public static Class getComponentType ( final Type type , final Class implClass , int index ) { Class [ ] componentTypes = getComponentTypes ( type , implClass ) ; if ( componentTypes == null ) { return null ; } if ( index < 0 ) { index += componentTypes . length ; } if ( index >= componentTypes . length ) { return null ; } return componentTypes [ index ] ; }


Input: Returns all component types of the given type . For example the following types all have the component - type MyClass : <ul > <li > MyClass [] < / li > <li > List&lt ; MyClass&gt ; < / li > <li > Foo&lt ; ? extends MyClass&gt ; < / li > <li > Bar&lt ; ? super MyClass&gt ; < / li > <li > &lt ; T extends MyClass&gt ; T [] < / li > < / ul > [CODESPLIT] public static Class [ ] getComponentTypes ( final Type type , final Class implClass ) { if ( type instanceof Class ) { Class clazz = ( Class ) type ; if ( clazz . isArray ( ) ) { return new Class [ ] { clazz . getComponentType ( ) } ; } } else if ( type instanceof ParameterizedType ) { ParameterizedType pt = ( ParameterizedType ) type ; Type [ ] generics = pt . getActualTypeArguments ( ) ; if ( generics . length == 0 ) { return null ; } Class [ ] types = new Class [ generics . length ] ; for ( int i = 0 ; i < generics . length ; i ++ ) { types [ i ] = getRawType ( generics [ i ] , implClass ) ; } return types ; } else if ( type instanceof GenericArrayType ) { GenericArrayType gat = ( GenericArrayType ) type ; Class rawType = getRawType ( gat . getGenericComponentType ( ) , implClass ) ; if ( rawType == null ) { return null ; } return new Class [ ] { rawType } ; } return null ; }


Input: Converts <code > Type< / code > to a <code > String< / code > . Supports successor interfaces : <ul > <li > <code > java . lang . Class< / code > - represents usual class< / li > <li > <code > java . lang . reflect . ParameterizedType< / code > - class with generic parameter ( e . g . <code > List< / code > ) < / li > <li > <code > java . lang . reflect . TypeVariable< / code > - generic type literal ( e . g . <code > List< / code > <code > T< / code > - type variable ) < / li > <li > <code > java . lang . reflect . WildcardType< / code > - wildcard type ( <code > List&lt ; ? extends Number&gt ; < / code > <code > ? extends Number< / code > - wildcard type ) < / li > <li > <code > java . lang . reflect . GenericArrayType< / code > - type for generic array ( e . g . <code > T [] < / code > <code > T< / code > - array type ) < / li > < / ul > [CODESPLIT] public static String typeToString ( final Type type ) { StringBuilder sb = new StringBuilder ( ) ; typeToString ( sb , type , new HashSet < Type > ( ) ) ; return sb . toString ( ) ; }


Input: Reads annotation value . Returns <code > null< / code > on error ( e . g . when value name not found ) . [CODESPLIT] public static Object readAnnotationValue ( final Annotation annotation , final String name ) { try { Method method = annotation . annotationType ( ) . getDeclaredMethod ( name ) ; return method . invoke ( annotation ) ; } catch ( Exception ignore ) { return null ; } }


Input: Emulates <code > Reflection . getCallerClass< / code > using standard API . This implementation uses custom <code > SecurityManager< / code > and it is the fastest . Other implementations are : <ul > <li > <code > new Throwable () . getStackTrace () [ callStackDepth ] < / code > < / li > <li > <code > Thread . currentThread () . getStackTrace () [ callStackDepth ] < / code > ( the slowest ) < / li > < / ul > <p > In case when usage of <code > SecurityManager< / code > is not allowed this method fails back to the second implementation . <p > Note that original <code > Reflection . getCallerClass< / code > is way faster then any emulation . [CODESPLIT] public static Class getCallerClass ( int framesToSkip ) { if ( SECURITY_MANAGER != null ) { return SECURITY_MANAGER . getCallerClass ( framesToSkip ) ; } StackTraceElement [ ] stackTraceElements = new Throwable ( ) . getStackTrace ( ) ; if ( framesToSkip >= 2 ) { framesToSkip += 4 ; } String className = stackTraceElements [ framesToSkip ] . getClassName ( ) ; try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException cnfex ) { throw new UnsupportedOperationException ( className + " not found." ) ; } }


Input: Smart variant of { [CODESPLIT] public static Class getCallerClass ( ) { String className = null ; StackTraceElement [ ] stackTraceElements = new Throwable ( ) . getStackTrace ( ) ; for ( StackTraceElement stackTraceElement : stackTraceElements ) { className = stackTraceElement . getClassName ( ) ; String methodName = stackTraceElement . getMethodName ( ) ; if ( methodName . equals ( "loadClass" ) ) { if ( className . contains ( ClassLoaderStrategy . class . getSimpleName ( ) ) ) { continue ; } if ( className . equals ( ClassLoaderUtil . class . getName ( ) ) ) { continue ; } } else if ( methodName . equals ( "getCallerClass" ) ) { continue ; } break ; } try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException cnfex ) { throw new UnsupportedOperationException ( className + " not found." ) ; } }


Input: Returns <code > enum< / code > class or <code > null< / code > if class is not an enum . [CODESPLIT] public static Class findEnum ( Class target ) { if ( target . isPrimitive ( ) ) { return null ; } while ( target != Object . class ) { if ( target . isEnum ( ) ) { return target ; } target = target . getSuperclass ( ) ; } return null ; }


Input: Returns the class of the immediate subclass of the given parent class for the given object instance ; or null if such immediate subclass cannot be uniquely identified for the given object instance . [CODESPLIT] public static Class < ? > childClassOf ( final Class < ? > parentClass , final Object instance ) { if ( instance == null || instance == Object . class ) { return null ; } if ( parentClass != null ) { if ( parentClass . isInterface ( ) ) { return null ; } } Class < ? > childClass = instance . getClass ( ) ; while ( true ) { Class < ? > parent = childClass . getSuperclass ( ) ; if ( parent == parentClass ) { return childClass ; } if ( parent == null ) { return null ; } childClass = parent ; } }


Input: Returns the jar file from which the given class is loaded ; or null if no such jar file can be located . [CODESPLIT] public static JarFile jarFileOf ( final Class < ? > klass ) { URL url = klass . getResource ( "/" + klass . getName ( ) . replace ( ' ' , ' ' ) + ".class" ) ; if ( url == null ) { return null ; } String s = url . getFile ( ) ; int beginIndex = s . indexOf ( "file:" ) + "file:" . length ( ) ; int endIndex = s . indexOf ( ".jar!" ) ; if ( endIndex == - 1 ) { return null ; } endIndex += ".jar" . length ( ) ; String f = s . substring ( beginIndex , endIndex ) ; // decode URL string - it may contain encoded chars (e.g. whitespaces) which are not supported for file-instances f = URLDecoder . decode ( f , "UTF-8" ) ; File file = new File ( f ) ; try { return file . exists ( ) ? new JarFile ( file ) : null ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } }


Input: Resolves class file name from class name by replacing dot s with / separator and adding class extension at the end . If array component type is returned . [CODESPLIT] public static String convertClassNameToFileName ( Class clazz ) { if ( clazz . isArray ( ) ) { clazz = clazz . getComponentType ( ) ; } return convertClassNameToFileName ( clazz . getName ( ) ) ; }


Input: Returns { [CODESPLIT] public static boolean isKotlinClass ( final Class type ) { final Annotation [ ] annotations = type . getAnnotations ( ) ; for ( Annotation annotation : annotations ) { if ( annotation . annotationType ( ) . getName ( ) . equals ( "kotlin.Metadata" ) ) { return true ; } } return false ; }


Input: Returns <code > true< / code > if type is some integer - like type : INTEGER SMALLINT TINYINT BIT . [CODESPLIT] public static boolean isIntegerType ( final int type ) { return ( type == Types . INTEGER ) || ( type == Types . SMALLINT ) || ( type == Types . TINYINT ) || ( type == Types . BIT ) ; }


Input: Puts a thread to sleep without throwing an InterruptedException . [CODESPLIT] public static void sleep ( final long ms ) { try { Thread . sleep ( ms ) ; } catch ( InterruptedException iex ) { Thread . currentThread ( ) . interrupt ( ) ; } }


Input: Puts a thread to sleep forever . [CODESPLIT] public static void sleep ( ) { try { Thread . sleep ( Long . MAX_VALUE ) ; } catch ( InterruptedException iex ) { Thread . currentThread ( ) . interrupt ( ) ; } }


Input: Waits for a object for synchronization purposes . [CODESPLIT] public static void wait ( final Object obj ) { synchronized ( obj ) { try { obj . wait ( ) ; } catch ( InterruptedException inex ) { Thread . currentThread ( ) . interrupt ( ) ; } } }


Input: ---------------------------------------------------------------- join [CODESPLIT] public static void join ( final Thread thread ) { try { thread . join ( ) ; } catch ( InterruptedException inex ) { Thread . currentThread ( ) . interrupt ( ) ; } }


Input: Creates new daemon thread factory . [CODESPLIT] public static ThreadFactory daemonThreadFactory ( final String name , final int priority ) { return new ThreadFactory ( ) { private AtomicInteger count = new AtomicInteger ( ) ; @ Override public Thread newThread ( final Runnable r ) { Thread thread = new Thread ( r ) ; thread . setName ( name + ' ' + count . incrementAndGet ( ) ) ; thread . setDaemon ( true ) ; thread . setPriority ( priority ) ; return thread ; } } ; }


Input: Returns the value . Value will be computed on first call . [CODESPLIT] @ Override public T get ( ) { if ( ! initialized ) { synchronized ( this ) { if ( ! initialized ) { final T t = supplier . get ( ) ; value = t ; initialized = true ; supplier = null ; return t ; } } } return value ; }


Input: Visits a parameter of this method . [CODESPLIT] public void visitParameter ( final String name , final int access ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { mv . visitParameter ( name , access ) ; } }


Input: Visits an annotation of this method . [CODESPLIT] public AnnotationVisitor visitAnnotation ( final String descriptor , final boolean visible ) { if ( mv != null ) { return mv . visitAnnotation ( descriptor , visible ) ; } return null ; }


Input: Visits an annotation on a type in the method signature . [CODESPLIT] public AnnotationVisitor visitTypeAnnotation ( final int typeRef , final TypePath typePath , final String descriptor , final boolean visible ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { return mv . visitTypeAnnotation ( typeRef , typePath , descriptor , visible ) ; } return null ; }


Input: Visits an annotation of a parameter this method . [CODESPLIT] public AnnotationVisitor visitParameterAnnotation ( final int parameter , final String descriptor , final boolean visible ) { if ( mv != null ) { return mv . visitParameterAnnotation ( parameter , descriptor , visible ) ; } return null ; }


Input:
Visits the current state of the local variables and operand stack elements . This method must ( * ) be called  just before any instruction  i that follows an unconditional branch instruction such as GOTO or THROW that is the target of a jump instruction or that starts an exception handler block . The visited types must describe the values of the local variables and of the operand stack elements  just before  i is executed .

 ( * ) this is mandatory only for classes whose version is greater than or equal to { @link Opcodes#V1_6 } .

 The frames of a method must be given either in expanded form or in compressed form ( all frames must use the same format i . e . you must not mix expanded and compressed frames within a single method ) : [CODESPLIT] public void visitFrame ( final int type , final int numLocal , final Object [ ] local , final int numStack , final Object [ ] stack ) { if ( mv != null ) { mv . visitFrame ( type , numLocal , local , numStack , stack ) ; } }


Input: Visits a field instruction . A field instruction is an instruction that loads or stores the value of a field of an object . [CODESPLIT] public void visitFieldInsn ( final int opcode , final String owner , final String name , final String descriptor ) { if ( mv != null ) { mv . visitFieldInsn ( opcode , owner , name , descriptor ) ; } }


Input: Visits a method instruction . A method instruction is an instruction that invokes a method . [CODESPLIT] public void visitMethodInsn ( final int opcode , final String owner , final String name , final String descriptor , final boolean isInterface ) { if ( api < Opcodes . ASM5 ) { if ( isInterface != ( opcode == Opcodes . INVOKEINTERFACE ) ) { throw new IllegalArgumentException ( "INVOKESPECIAL/STATIC on interfaces requires ASM5" ) ; } visitMethodInsn ( opcode , owner , name , descriptor ) ; return ; } if ( mv != null ) { mv . visitMethodInsn ( opcode , owner , name , descriptor , isInterface ) ; } }


Input: Visits an invokedynamic instruction . [CODESPLIT] public void visitInvokeDynamicInsn ( final String name , final String descriptor , final Handle bootstrapMethodHandle , final Object ... bootstrapMethodArguments ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { mv . visitInvokeDynamicInsn ( name , descriptor , bootstrapMethodHandle , bootstrapMethodArguments ) ; } }


Input: Visits a jump instruction . A jump instruction is an instruction that may jump to another instruction . [CODESPLIT] public void visitJumpInsn ( final int opcode , final Label label ) { if ( mv != null ) { mv . visitJumpInsn ( opcode , label ) ; } }


Input: Visits a MULTIANEWARRAY instruction . [CODESPLIT] public void visitMultiANewArrayInsn ( final String descriptor , final int numDimensions ) { if ( mv != null ) { mv . visitMultiANewArrayInsn ( descriptor , numDimensions ) ; } }


Input: Visits a try catch block . [CODESPLIT] public void visitTryCatchBlock ( final Label start , final Label end , final Label handler , final String type ) { if ( mv != null ) { mv . visitTryCatchBlock ( start , end , handler , type ) ; } }


Input: Visits an annotation on a local variable type . [CODESPLIT] public AnnotationVisitor visitLocalVariableAnnotation ( final int typeRef , final TypePath typePath , final Label [ ] start , final Label [ ] end , final int [ ] index , final String descriptor , final boolean visible ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { return mv . visitLocalVariableAnnotation ( typeRef , typePath , start , end , index , descriptor , visible ) ; } return null ; }


Input: Convert Java Properties to Jodd Props format [CODESPLIT] void convertToWriter ( final Writer writer , final Properties properties , final Map < String , Properties > profiles ) throws IOException { final BufferedWriter bw = getBufferedWriter ( writer ) ; writeBaseAndProfileProperties ( bw , properties , profiles ) ; writeProfilePropertiesThatAreNotInTheBase ( bw , properties , profiles ) ; bw . flush ( ) ; }


Input: Reads data from input stream into byte array and stores file size . [CODESPLIT] @ Override public void processStream ( ) throws IOException { FastByteArrayOutputStream out = new FastByteArrayOutputStream ( ) ; size = 0 ; if ( maxFileSize == - 1 ) { size += input . copyAll ( out ) ; } else { size += input . copyMax ( out , maxFileSize + 1 ) ; // one more byte to detect larger files if ( size > maxFileSize ) { fileTooBig = true ; valid = false ; input . skipToBoundary ( ) ; return ; } } data = out . toByteArray ( ) ; size = data . length ; valid = true ; }


Input: Returns <code > true< / code > if there is { [CODESPLIT] @ Override public boolean hasNext ( ) { if ( hasNext == null ) { hasNext = Boolean . valueOf ( moveToNext ( ) ) ; } return hasNext . booleanValue ( ) ; }


Input: Returns next mapped object . [CODESPLIT] @ Override public T next ( ) { if ( hasNext == null ) { hasNext = Boolean . valueOf ( moveToNext ( ) ) ; } if ( hasNext == false ) { throw new NoSuchElementException ( ) ; } if ( ! entityAwareMode ) { hasNext = null ; return newElement ; } count ++ ; T result = previousElement ; previousElement = newElement ; hasNext = null ; return result ; }


Input: Moves to next element . [CODESPLIT] private boolean moveToNext ( ) { if ( last ) { // last has been set to true, so no more rows to iterate - close everything if ( closeOnEnd ) { query . close ( ) ; } else { query . closeResultSet ( resultSetMapper . getResultSet ( ) ) ; } return false ; } while ( true ) { if ( ! resultSetMapper . next ( ) ) { // no more rows, no more parsing, previousElement is the last one to iterate last = true ; return entityAwareMode ; } // parse row Object [ ] objects = resultSetMapper . parseObjects ( types ) ; Object row = query . resolveRowResults ( objects ) ; newElement = ( T ) row ; if ( entityAwareMode ) { if ( count == 0 && previousElement == null ) { previousElement = newElement ; continue ; } if ( previousElement != null && newElement != null ) { boolean equals ; if ( newElement . getClass ( ) . isArray ( ) ) { equals = Arrays . equals ( ( Object [ ] ) previousElement , ( Object [ ] ) newElement ) ; } else { equals = previousElement . equals ( newElement ) ; } if ( equals ) { continue ; } } } break ; } return true ; }


Input: Joins arrays . Component type is resolved from the array argument . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] join ( T [ ] ... arrays ) { Class < T > componentType = ( Class < T > ) arrays . getClass ( ) . getComponentType ( ) . getComponentType ( ) ; return join ( componentType , arrays ) ; }


Input: Joins arrays using provided component type . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] join ( Class < T > componentType , T [ ] [ ] arrays ) { if ( arrays . length == 1 ) { return arrays [ 0 ] ; } int length = 0 ; for ( T [ ] array : arrays ) { length += array . length ; } T [ ] result = ( T [ ] ) Array . newInstance ( componentType , length ) ; length = 0 ; for ( T [ ] array : arrays ) { System . arraycopy ( array , 0 , result , length , array . length ) ; length += array . length ; } return result ; }


Input: Join <code > double< / code > arrays . [CODESPLIT] public static double [ ] join ( double [ ] ... arrays ) { if ( arrays . length == 0 ) { return new double [ 0 ] ; } if ( arrays . length == 1 ) { return arrays [ 0 ] ; } int length = 0 ; for ( double [ ] array : arrays ) { length += array . length ; } double [ ] result = new double [ length ] ; length = 0 ; for ( double [ ] array : arrays ) { System . arraycopy ( array , 0 , result , length , array . length ) ; length += array . length ; } return result ; }


Input: Resizes an array . [CODESPLIT] public static < T > T [ ] resize ( T [ ] buffer , int newSize ) { Class < T > componentType = ( Class < T > ) buffer . getClass ( ) . getComponentType ( ) ; T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , newSize ) ; System . arraycopy ( buffer , 0 , temp , 0 , buffer . length >= newSize ? newSize : buffer . length ) ; return temp ; }


Input: Resizes a <code > String< / code > array . [CODESPLIT] public static String [ ] resize ( String [ ] buffer , int newSize ) { String [ ] temp = new String [ newSize ] ; System . arraycopy ( buffer , 0 , temp , 0 , buffer . length >= newSize ? newSize : buffer . length ) ; return temp ; }


Input: Appends an element to array . [CODESPLIT] public static < T > T [ ] append ( T [ ] buffer , T newElement ) { T [ ] t = resize ( buffer , buffer . length + 1 ) ; t [ buffer . length ] = newElement ; return t ; }


Input: Removes sub - array . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] remove ( T [ ] buffer , int offset , int length , Class < T > componentType ) { int len2 = buffer . length - length ; T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , len2 ) ; System . arraycopy ( buffer , 0 , temp , 0 , offset ) ; System . arraycopy ( buffer , offset + length , temp , offset , len2 - offset ) ; return temp ; }


Input: Removes sub - array from <code > boolean< / code > array . [CODESPLIT] public static boolean [ ] remove ( boolean [ ] buffer , int offset , int length ) { int len2 = buffer . length - length ; boolean [ ] temp = new boolean [ len2 ] ; System . arraycopy ( buffer , 0 , temp , 0 , offset ) ; System . arraycopy ( buffer , offset + length , temp , offset , len2 - offset ) ; return temp ; }


Input: Returns subarray . [CODESPLIT] public static < T > T [ ] subarray ( T [ ] buffer , int offset , int length ) { Class < T > componentType = ( Class < T > ) buffer . getClass ( ) . getComponentType ( ) ; return subarray ( buffer , offset , length , componentType ) ; }


Input: Returns subarray . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] subarray ( T [ ] buffer , int offset , int length , Class < T > componentType ) { T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , length ) ; System . arraycopy ( buffer , offset , temp , 0 , length ) ; return temp ; }


Input: Returns subarray . [CODESPLIT] public static String [ ] subarray ( String [ ] buffer , int offset , int length ) { String [ ] temp = new String [ length ] ; System . arraycopy ( buffer , offset , temp , 0 , length ) ; return temp ; }


Input: Inserts one array into another <code > String< / code > array . [CODESPLIT] public static String [ ] insert ( String [ ] dest , String [ ] src , int offset ) { String [ ] temp = new String [ dest . length + src . length ] ; System . arraycopy ( dest , 0 , temp , 0 , offset ) ; System . arraycopy ( src , 0 , temp , offset , src . length ) ; System . arraycopy ( dest , offset , temp , src . length + offset , dest . length - offset ) ; return temp ; }


Input: Inserts one array into another at given offset . [CODESPLIT] public static < T > T [ ] insertAt ( T [ ] dest , T [ ] src , int offset ) { Class < T > componentType = ( Class < T > ) dest . getClass ( ) . getComponentType ( ) ; return insertAt ( dest , src , offset , componentType ) ; }


Input: Inserts one array into another at given offset . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] insertAt ( T [ ] dest , T [ ] src , int offset , Class componentType ) { T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , dest . length + src . length - 1 ) ; System . arraycopy ( dest , 0 , temp , 0 , offset ) ; System . arraycopy ( src , 0 , temp , offset , src . length ) ; System . arraycopy ( dest , offset + 1 , temp , src . length + offset , dest . length - offset - 1 ) ; return temp ; }


Input: Converts to primitive array . [CODESPLIT] public static byte [ ] values ( Byte [ ] array ) { byte [ ] dest = new byte [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Byte v = array [ i ] ; if ( v != null ) { dest [ i ] = v . byteValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Byte [ ] valuesOf ( byte [ ] array ) { Byte [ ] dest = new Byte [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Byte . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static char [ ] values ( Character [ ] array ) { char [ ] dest = new char [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Character v = array [ i ] ; if ( v != null ) { dest [ i ] = v . charValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Character [ ] valuesOf ( char [ ] array ) { Character [ ] dest = new Character [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Character . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static short [ ] values ( Short [ ] array ) { short [ ] dest = new short [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Short v = array [ i ] ; if ( v != null ) { dest [ i ] = v . shortValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Short [ ] valuesOf ( short [ ] array ) { Short [ ] dest = new Short [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Short . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static int [ ] values ( Integer [ ] array ) { int [ ] dest = new int [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Integer v = array [ i ] ; if ( v != null ) { dest [ i ] = v . intValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Integer [ ] valuesOf ( int [ ] array ) { Integer [ ] dest = new Integer [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Integer . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static long [ ] values ( Long [ ] array ) { long [ ] dest = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Long v = array [ i ] ; if ( v != null ) { dest [ i ] = v . longValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Long [ ] valuesOf ( long [ ] array ) { Long [ ] dest = new Long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Long . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static float [ ] values ( Float [ ] array ) { float [ ] dest = new float [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Float v = array [ i ] ; if ( v != null ) { dest [ i ] = v . floatValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Float [ ] valuesOf ( float [ ] array ) { Float [ ] dest = new Float [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Float . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static double [ ] values ( Double [ ] array ) { double [ ] dest = new double [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Double v = array [ i ] ; if ( v != null ) { dest [ i ] = v . doubleValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Double [ ] valuesOf ( double [ ] array ) { Double [ ] dest = new Double [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Double . valueOf ( array [ i ] ) ; } return dest ; }


Input: Converts to primitive array . [CODESPLIT] public static boolean [ ] values ( Boolean [ ] array ) { boolean [ ] dest = new boolean [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Boolean v = array [ i ] ; if ( v != null ) { dest [ i ] = v . booleanValue ( ) ; } } return dest ; }


Input: Converts to object array . [CODESPLIT] public static Boolean [ ] valuesOf ( boolean [ ] array ) { Boolean [ ] dest = new Boolean [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Boolean . valueOf ( array [ i ] ) ; } return dest ; }


Input: Finds the first occurrence in an array from specified given position and upto given length . [CODESPLIT] public static int indexOf ( byte [ ] array , byte value , int startIndex , int endIndex ) { for ( int i = startIndex ; i < endIndex ; i ++ ) { if ( array [ i ] == value ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence of an element in an array . [CODESPLIT] public static int indexOf ( char [ ] array , char value ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == value ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence of value in <code > float< / code > array . [CODESPLIT] public static int indexOf ( float [ ] array , float value ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( Float . compare ( array [ i ] , value ) == 0 ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence in <code > float< / code > array from specified given position and upto given length . [CODESPLIT] public static int indexOf ( float [ ] array , float value , int startIndex , int endIndex ) { for ( int i = startIndex ; i < endIndex ; i ++ ) { if ( Float . compare ( array [ i ] , value ) == 0 ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence of value in <code > double< / code > array . [CODESPLIT] public static int indexOf ( double [ ] array , double value ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( Double . compare ( array [ i ] , value ) == 0 ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence in <code > double< / code > array from specified given position and upto given length . [CODESPLIT] public static int indexOf ( double [ ] array , double value , int startIndex , int endIndex ) { for ( int i = startIndex ; i < endIndex ; i ++ ) { if ( Double . compare ( array [ i ] , value ) == 0 ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence in an array . [CODESPLIT] public static int indexOf ( Object [ ] array , Object value ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] . equals ( value ) ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence in an array from specified given position . [CODESPLIT] public static int indexOf ( byte [ ] array , byte [ ] sub , int startIndex ) { return indexOf ( array , sub , startIndex , array . length ) ; }


Input: Finds the first occurrence in an array from specified given position and upto given length . [CODESPLIT] public static int indexOf ( double [ ] array , double [ ] sub , int startIndex , int endIndex ) { int sublen = sub . length ; if ( sublen == 0 ) { return startIndex ; } int total = endIndex - sublen + 1 ; double c = sub [ 0 ] ; mainloop : for ( int i = startIndex ; i < total ; i ++ ) { if ( Double . compare ( array [ i ] , c ) != 0 ) { continue ; } int j = 1 ; int k = i + 1 ; while ( j < sublen ) { if ( Double . compare ( sub [ j ] , array [ k ] ) != 0 ) { continue mainloop ; } j ++ ; k ++ ; } return i ; } return - 1 ; }


Input: Converts an array to string array . [CODESPLIT] public static String [ ] toStringArray ( Object [ ] array ) { if ( array == null ) { return null ; } String [ ] result = new String [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = StringUtil . toString ( array [ i ] ) ; } return result ; }


Input: Converts an array to string array . [CODESPLIT] public static String [ ] toStringArray ( String [ ] array ) { if ( array == null ) { return null ; } String [ ] result = new String [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = String . valueOf ( array [ i ] ) ; } return result ; }


Input: Enables XHTML mode . [CODESPLIT] public LagartoDOMBuilder enableXhtmlMode ( ) { config . ignoreWhitespacesBetweenTags = false ; // collect all whitespaces config . setCaseSensitive ( true ) ; // XHTML is case sensitive config . setEnableRawTextModes ( false ) ; // all tags are parsed in the same way config . enabledVoidTags = true ; // list of void tags config . selfCloseVoidTags = true ; // self close void tags config . impliedEndTags = false ; // no implied tag ends config . setEnableConditionalComments ( false ) ; // don't enable IE conditional comments config . setParseXmlTags ( false ) ; // enable XML mode in parsing return this ; }


Input: Creates DOM tree from provided content . [CODESPLIT] @ Override public Document parse ( final char [ ] content ) { LagartoParser lagartoParser = new LagartoParser ( content ) ; return doParse ( lagartoParser ) ; }


Input: Parses the content using provided lagarto parser . [CODESPLIT] protected Document doParse ( final LagartoParser lagartoParser ) { lagartoParser . setConfig ( config ) ; LagartoDOMBuilderTagVisitor domBuilderTagVisitor = new LagartoDOMBuilderTagVisitor ( this ) ; lagartoParser . parse ( domBuilderTagVisitor ) ; return domBuilderTagVisitor . getDocument ( ) ; }


Input: ----------------------------------------------------------------------------------------------- [CODESPLIT] @ Override public void visitParameter ( final String name , final int access ) { if ( parameters == null ) { parameters = new ByteVector ( ) ; } ++ parametersCount ; parameters . putShort ( ( name == null ) ? 0 : symbolTable . addConstantUtf8 ( name ) ) . putShort ( access ) ; }


Input: Computes all the stack map frames of the method from scratch . [CODESPLIT] private void computeAllFrames ( ) { // Complete the control flow graph with exception handler blocks. Handler handler = firstHandler ; while ( handler != null ) { String catchTypeDescriptor = handler . catchTypeDescriptor == null ? "java/lang/Throwable" : handler . catchTypeDescriptor ; int catchType = Frame . getAbstractTypeFromInternalName ( symbolTable , catchTypeDescriptor ) ; // Mark handlerBlock as an exception handler. Label handlerBlock = handler . handlerPc . getCanonicalInstance ( ) ; handlerBlock . flags |= Label . FLAG_JUMP_TARGET ; // Add handlerBlock as a successor of all the basic blocks in the exception handler range. Label handlerRangeBlock = handler . startPc . getCanonicalInstance ( ) ; Label handlerRangeEnd = handler . endPc . getCanonicalInstance ( ) ; while ( handlerRangeBlock != handlerRangeEnd ) { handlerRangeBlock . outgoingEdges = new Edge ( catchType , handlerBlock , handlerRangeBlock . outgoingEdges ) ; handlerRangeBlock = handlerRangeBlock . nextBasicBlock ; } handler = handler . nextHandler ; } // Create and visit the first (implicit) frame. Frame firstFrame = firstBasicBlock . frame ; firstFrame . setInputFrameFromDescriptor ( symbolTable , accessFlags , descriptor , this . maxLocals ) ; firstFrame . accept ( this ) ; // Fix point algorithm: add the first basic block to a list of blocks to process (i.e. blocks // whose stack map frame has changed) and, while there are blocks to process, remove one from // the list and update the stack map frames of its successor blocks in the control flow graph // (which might change them, in which case these blocks must be processed too, and are thus // added to the list of blocks to process). Also compute the maximum stack size of the method, // as a by-product. Label listOfBlocksToProcess = firstBasicBlock ; listOfBlocksToProcess . nextListElement = Label . EMPTY_LIST ; int maxStackSize = 0 ; while ( listOfBlocksToProcess != Label . EMPTY_LIST ) { // Remove a basic block from the list of blocks to process. Label basicBlock = listOfBlocksToProcess ; listOfBlocksToProcess = listOfBlocksToProcess . nextListElement ; basicBlock . nextListElement = null ; // By definition, basicBlock is reachable. basicBlock . flags |= Label . FLAG_REACHABLE ; // Update the (absolute) maximum stack size. int maxBlockStackSize = basicBlock . frame . getInputStackSize ( ) + basicBlock . outputStackMax ; if ( maxBlockStackSize > maxStackSize ) { maxStackSize = maxBlockStackSize ; } // Update the successor blocks of basicBlock in the control flow graph. Edge outgoingEdge = basicBlock . outgoingEdges ; while ( outgoingEdge != null ) { Label successorBlock = outgoingEdge . successor . getCanonicalInstance ( ) ; boolean successorBlockChanged = basicBlock . frame . merge ( symbolTable , successorBlock . frame , outgoingEdge . info ) ; if ( successorBlockChanged && successorBlock . nextListElement == null ) { // If successorBlock has changed it must be processed. Thus, if it is not already in the // list of blocks to process, add it to this list. successorBlock . nextListElement = listOfBlocksToProcess ; listOfBlocksToProcess = successorBlock ; } outgoingEdge = outgoingEdge . nextEdge ; } } // Loop over all the basic blocks and visit the stack map frames that must be stored in the // StackMapTable attribute. Also replace unreachable code with NOP* ATHROW, and remove it from // exception handler ranges. Label basicBlock = firstBasicBlock ; while ( basicBlock != null ) { if ( ( basicBlock . flags & ( Label . FLAG_JUMP_TARGET | Label . FLAG_REACHABLE ) ) == ( Label . FLAG_JUMP_TARGET | Label . FLAG_REACHABLE ) ) { basicBlock . frame . accept ( this ) ; } if ( ( basicBlock . flags & Label . FLAG_REACHABLE ) == 0 ) { // Find the start and end bytecode offsets of this unreachable block. Label nextBasicBlock = basicBlock . nextBasicBlock ; int startOffset = basicBlock . bytecodeOffset ; int endOffset = ( nextBasicBlock == null ? code . length : nextBasicBlock . bytecodeOffset ) - 1 ; if ( endOffset >= startOffset ) { // Replace its instructions with NOP ... NOP ATHROW. for ( int i = startOffset ; i < endOffset ; ++ i ) { code . data [ i ] = Opcodes . NOP ; } code . data [ endOffset ] = ( byte ) Opcodes . ATHROW ; // Emit a frame for this unreachable block, with no local and a Throwable on the stack // (so that the ATHROW could consume this Throwable if it were reachable). int frameIndex = visitFrameStart ( startOffset , /* numLocal = */ 0 , /* numStack = */ 1 ) ; currentFrame [ frameIndex ] = Frame . getAbstractTypeFromInternalName ( symbolTable , "java/lang/Throwable" ) ; visitFrameEnd ( ) ; // Remove this unreachable basic block from the exception handler ranges. firstHandler = Handler . removeRange ( firstHandler , basicBlock , nextBasicBlock ) ; // The maximum stack size is now at least one, because of the Throwable declared above. maxStackSize = Math . max ( maxStackSize , 1 ) ; } } basicBlock = basicBlock . nextBasicBlock ; } this . maxStack = maxStackSize ; }