idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
36,700
protected static Map < String , String > initializeSystemProperties ( final String [ ] args ) { final Map < String , String > result = new HashMap < > ( ) ; final Pattern pattern = Pattern . compile ( "-D(.+)=(.+)" ) ; for ( final String arg : args ) { final Matcher matcher = pattern . matcher ( arg ) ; if ( matcher . ...
Initializes system properties based on the arguments passed
36,701
protected static boolean initializeLogging ( ) { try { { final URL url = Main . class . getResource ( "log4j-initial.xml" ) ; assert url != null ; DOMConfigurator . configure ( url ) ; } if ( ClassLoaderUtils . IS_WEB_START ) { final URL url = Main . class . getResource ( "log4j-jnlp.xml" ) ; assert url != null ; print...
Initializes logging specifically by looking for log4j . xml or log4j . properties file in DataCleaner s home directory .
36,702
public Packer setContainer ( final Container cont ) throws IllegalAccessException { if ( container != null ) { final Packer p = ( Packer ) clone ( ) ; container . setLayout ( p ) ; } container = cont ; cont . setLayout ( this ) ; return this ; }
Set the designated container for objects packed by this instance .
36,703
public Packer pack ( final Component cp ) { if ( container != null ) { container . add ( cp ) ; } comp = cp ; gc = new GridBagConstraints ( ) ; setConstraints ( comp , gc ) ; return this ; }
Establishes a new set of constraints to layout the widget passed . The created constraints are applied to the passed Component and if a Container is known to this object the component is added to the known container .
36,704
public Packer setAnchorNorth ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . NORTH ; } else { gc . anchor &= ~ GridBagConstraints . NORTH ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = NORTH to the constraints for the current component if how == true remove it if false .
36,705
public Packer setAnchorSouth ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . SOUTH ; } else { gc . anchor &= ~ GridBagConstraints . SOUTH ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = SOUTH to the constraints for the current component if how == true remove it if false .
36,706
public Packer setAnchorEast ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . EAST ; } else { gc . anchor &= ~ GridBagConstraints . EAST ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = EAST to the constraints for the current component if how == true remove it if false .
36,707
public Packer setAnchorWest ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . WEST ; } else { gc . anchor &= ~ GridBagConstraints . WEST ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = WEST to the constraints for the current component if how == true remove it if false .
36,708
public Packer setAnchorNorthWest ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . NORTHWEST ; } else { gc . anchor &= ~ GridBagConstraints . NORTHWEST ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = NORTHWEST to the constraints for the current component if how == true remove it if false .
36,709
public Packer setAnchorSouthWest ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . SOUTHWEST ; } else { gc . anchor &= ~ GridBagConstraints . SOUTHWEST ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = SOUTHWEST to the constraints for the current component if how == true remove it if false .
36,710
public Packer setAnchorNorthEast ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . NORTHEAST ; } else { gc . anchor &= ~ GridBagConstraints . NORTHEAST ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = NORTHEAST to the constraints for the current component if how == true remove it if false .
36,711
public Packer setAnchorSouthEast ( final boolean how ) { if ( how == true ) { gc . anchor = GridBagConstraints . SOUTHEAST ; } else { gc . anchor &= ~ GridBagConstraints . SOUTHEAST ; } setConstraints ( comp , gc ) ; return this ; }
Add anchor = SOUTHEAST to the constraints for the current component if how == true remove it if false .
36,712
public Packer setXLeftRelative ( final boolean how ) { if ( how == true ) { gc . gridx = GridBagConstraints . RELATIVE ; } else { gc . gridx = 0 ; } setConstraints ( comp , gc ) ; return this ; }
Add gridx = RELATIVE to the constraints for the current component if how == true 0 it if false .
36,713
public Packer setYTopRelative ( final boolean how ) { if ( how == true ) { gc . gridy = GridBagConstraints . RELATIVE ; } else { gc . gridy = 0 ; } setConstraints ( comp , gc ) ; return this ; }
Add gridy = RELATIVE to the constraints for the current component if how == true 0 it if false .
36,714
public Packer setFillX ( final boolean how ) { if ( how == true ) { gc . fill = GridBagConstraints . HORIZONTAL ; gc . weightx = 1 ; } else { gc . weightx = 0 ; gc . fill = 0 ; } setConstraints ( comp , gc ) ; return this ; }
Add fill = HORIZONTAL weightx = 1 to the constraints for the current component if how == true . fill = 0 weightx = 0 if how is false .
36,715
public Packer fillx ( final double wtx ) { gc . fill = GridBagConstraints . HORIZONTAL ; gc . weightx = wtx ; setConstraints ( comp , gc ) ; return this ; }
Add fill = HORIZONTAL weightx = wtx to the constraints for the current component .
36,716
public Packer setFillY ( final boolean how ) { if ( how == true ) { gc . fill = GridBagConstraints . VERTICAL ; gc . weighty = 1 ; } else { gc . weighty = 0 ; gc . fill = 0 ; } setConstraints ( comp , gc ) ; return this ; }
Add fill = VERITCAL to the constraints for the current component if how == true 1 it if false .
36,717
public Packer filly ( final double wty ) { gc . fill = GridBagConstraints . VERTICAL ; gc . weighty = wty ; setConstraints ( comp , gc ) ; return this ; }
Add fill = VERTICAL weighty = wty to the constraints for the current component .
36,718
public Packer setFillBoth ( final boolean how ) { if ( how == true ) { gc . fill = GridBagConstraints . BOTH ; gc . weightx = 1 ; gc . weighty = 1 ; } else { gc . weightx = 0 ; gc . weighty = 0 ; gc . fill = 0 ; } setConstraints ( comp , gc ) ; return this ; }
Add fill = BOTH weightx = 1 weighty = 1 to the constraints for the current component if how == true fill = 0 weightx = 0 weighty = 0 if it is false .
36,719
public Packer fillboth ( final double wtx , final double wty ) { gc . fill = GridBagConstraints . BOTH ; gc . weightx = wtx ; gc . weighty = wty ; setConstraints ( comp , gc ) ; return this ; }
Add fill = BOTH weighty = 1 weightx = 1 to the constraints for the current component .
36,720
public Packer setInsetTop ( final int val ) { Insets i = gc . insets ; if ( i == null ) { i = new Insets ( 0 , 0 , 0 , 0 ) ; } gc . insets = new Insets ( val , i . left , i . bottom , i . right ) ; setConstraints ( comp , gc ) ; return this ; }
sets top Insets on the constraints for the current component to the value specified .
36,721
public Packer setInsetBottom ( final int val ) { Insets i = gc . insets ; if ( i == null ) { i = new Insets ( 0 , 0 , 0 , 0 ) ; } gc . insets = new Insets ( i . top , i . left , val , i . right ) ; setConstraints ( comp , gc ) ; return this ; }
sets bottom Insets on the constraints for the current component to the value specified .
36,722
public Packer setInsetLeft ( final int val ) { Insets i = gc . insets ; if ( i == null ) { i = new Insets ( 0 , 0 , 0 , 0 ) ; } gc . insets = new Insets ( i . top , val , i . bottom , i . right ) ; setConstraints ( comp , gc ) ; return this ; }
sets left Insets on the constraints for the current component to the value specified .
36,723
public Packer setInsetRight ( final int val ) { Insets i = gc . insets ; if ( i == null ) { i = new Insets ( 0 , 0 , 0 , 0 ) ; } gc . insets = new Insets ( i . top , i . left , i . bottom , val ) ; setConstraints ( comp , gc ) ; return this ; }
sets right Insets on the constraints for the current component to the value specified .
36,724
public static void removeSshCertificateChecks ( final HttpClient httpClient ) throws IllegalStateException { try { final SSLContext sslContext = SSLContext . getInstance ( "SSL" ) ; final TrustManager trustManager = new NaiveTrustManager ( ) ; sslContext . init ( null , new TrustManager [ ] { trustManager } , new Secur...
Removes the certificate checks of HTTPS traffic on a HTTP client . Use with caution!
36,725
public AnalyzerJob getAnalyzerJob ( final String descriptorName , final String analyzerName , final String analyzerInputName ) { List < AnalyzerJob > candidates = new ArrayList < > ( _jobs ) ; candidates = CollectionUtils2 . refineCandidates ( candidates , o -> { final String actualDescriptorName = o . getDescriptor ( ...
Gets the best candidate analyzer job based on search criteria offered in parameters .
36,726
public static boolean isSingleWord ( String value ) { if ( value == null ) { return false ; } value = value . trim ( ) ; if ( value . isEmpty ( ) ) { return false ; } return ! SINGLE_WORD_PATTERN . matcher ( value ) . matches ( ) ; }
Determines if a String represents a single word . A single word is defined as a non - null string containing no word boundaries after trimming .
36,727
public void autoMap ( final Datastore datastore ) { setDatastore ( datastore ) ; try ( DatastoreConnection con = datastore . openConnection ( ) ) { final SchemaNavigator schemaNavigator = con . getSchemaNavigator ( ) ; for ( final Entry < String , Column > entry : _map . entrySet ( ) ) { if ( entry . getValue ( ) == nu...
Automatically maps all unmapped paths by looking them up in a datastore .
36,728
public boolean endLink ( final Object endVertex , final MouseEvent mouseEvent ) { logger . debug ( "endLink({})" , endVertex ) ; boolean result = false ; if ( _startVertex != null && endVertex != null ) { if ( mouseEvent . getButton ( ) == MouseEvent . BUTTON1 ) { final boolean created = createLink ( _startVertex , end...
If startVertex is non - null this method will attempt to end the link - painting at the given endVertex
36,729
private boolean scopeUpdatePermitted ( final AnalysisJobBuilder sourceAnalysisJobBuilder , final ComponentBuilder componentBuilder ) { if ( sourceAnalysisJobBuilder != componentBuilder . getAnalysisJobBuilder ( ) ) { if ( componentBuilder . getInput ( ) . length > 0 || componentBuilder . getComponentRequirement ( ) != ...
This will check if components are in a different scope and ask the user for permission to change the scope of the target component
36,730
public static Color colorBetween ( final Color c1 , final Color c2 ) { final int red = ( c1 . getRed ( ) + c2 . getRed ( ) ) / 2 ; final int green = ( c1 . getGreen ( ) + c2 . getGreen ( ) ) / 2 ; final int blue = ( c1 . getBlue ( ) + c2 . getBlue ( ) ) / 2 ; return new Color ( red , green , blue ) ; }
Creates a color that is in between two colors in terms of RGB balance .
36,731
public static DCPanel decorateWithShadow ( final JComponent comp , final boolean outline , final int margin ) { final DCPanel panel = new DCPanel ( ) ; panel . setLayout ( new BorderLayout ( ) ) ; Border border = BORDER_SHADOW ; if ( outline ) { border = new CompoundBorder ( border , BORDER_THIN ) ; } if ( margin > 0 )...
Decorates a JComponent with a nice shadow border . Since not all JComponents handle opacity correctly they will be wrapped inside a DCPanel which actually has the border .
36,732
public static Font findCompatibleFont ( final String text , final Font fallbackFont ) { final String [ ] searchFonts = new String [ ] { Font . SANS_SERIF , Font . SERIF , "Verdana" , "Arial Unicode MS" , "MS UI Gothic" , "MS Mincho" , "MS Gothic" , "Osaka" } ; for ( final String fontName : searchFonts ) { Font font = f...
Finds a font that is capable of displaying the provided text .
36,733
private InputColumn < ? > findOrderByColumn ( final AnalysisJobBuilder jobBuilder ) { final Table sourceTable = jobBuilder . getSourceTables ( ) . get ( 0 ) ; final List < Column > primaryKeys = sourceTable . getPrimaryKeys ( ) ; if ( primaryKeys . size ( ) == 1 ) { final Column primaryKey = primaryKeys . get ( 0 ) ; f...
Finds a source column which is appropriate for an ORDER BY clause in the generated paginated queries
36,734
protected String getCellValue ( final HtmlRenderingContext context , final int row , final int col , final Object value ) { final String stringValue = LabelUtils . getValueLabel ( value ) ; return context . escapeHtml ( stringValue ) ; }
Overrideable method for defining a cell s literal HTML value in the table
36,735
public Injector openAnalysisJob ( final FileObject file ) { final JaxbJobReader reader = new JaxbJobReader ( _configuration ) ; try { final AnalysisJobBuilder ajb = reader . create ( file ) ; return openAnalysisJob ( file , ajb ) ; } catch ( final NoSuchComponentException e ) { final String message ; if ( Version . EDI...
Opens a job file
36,736
public Injector openAnalysisJob ( final FileObject fileObject , final AnalysisJobBuilder ajb ) { final File file = VFSUtils . toFile ( fileObject ) ; if ( file != null ) { _userPreferences . setAnalysisJobDirectory ( file . getParentFile ( ) ) ; _userPreferences . addRecentJobFile ( fileObject ) ; } return Guice . crea...
Opens a job builder
36,737
public static FileSystemManager getFileSystemManager ( ) { try { final FileSystemManager manager = VFS . getManager ( ) ; if ( manager . getBaseFile ( ) == null ) { ( ( DefaultFileSystemManager ) manager ) . setBaseFile ( new File ( "." ) ) ; } return manager ; } catch ( final FileSystemException e ) { throw new Illega...
Gets the file system manager to use in typical scenarios .
36,738
private < E > E createCustomElement ( final CustomElementType customElementType , final Class < E > expectedClazz , final DataCleanerConfiguration configuration , final boolean initialize ) { final InjectionManager injectionManager = configuration . getEnvironment ( ) . getInjectionManagerFactory ( ) . getInjectionMana...
Creates a custom component based on an element which specified just a class name and an optional set of properties .
36,739
public static Object [ ] collapse ( String aString , int anInt ) { return new Object [ ] { aString , Integer . valueOf ( anInt ) } ; }
Collapse a String and int into an array
36,740
public Method createJavaMethod ( ) { Class < ? > clazz = rtype . getClazz ( ) ; String name = methodMember . getName ( ) ; String methodDescriptor = methodMember . getDescriptor ( ) ; ClassLoader classLoader = rtype . getTypeRegistry ( ) . getClassLoader ( ) ; try { Class < ? > [ ] params = Utils . toParamClasses ( met...
Create a mock Java Method which is dependent on ReflectiveInterceptor to catch calls to invoke .
36,741
public void setValue ( ReloadableType rtype , Object instance , Object value , String name ) throws IllegalAccessException { FieldMember fieldmember = rtype . findInstanceField ( name ) ; if ( fieldmember == null ) { FieldReaderWriter frw = rtype . locateField ( name ) ; if ( frw == null ) { log . info ( "Unexpectedly ...
Set the value of a field .
36,742
private void collectAll ( MethodProvider methodProvider , Map < String , Invoker > found ) { MethodProvider [ ] itfs = methodProvider . getInterfaces ( ) ; for ( int i = itfs . length - 1 ; i >= 0 ; i -- ) { collectAll ( itfs [ i ] , found ) ; } MethodProvider supr = methodProvider . getSuper ( ) ; if ( supr != null &&...
Collect all public methods from methodProvider and its supertypes into the found hasmap indexed by name + descriptor .
36,743
public static void generateJLObjectStream_hasStaticInitializer ( ClassWriter cw , String classname ) { FieldVisitor fv = cw . visitField ( ACC_PUBLIC + ACC_STATIC , jloObjectStream_hasInitializerMethod , "Ljava/lang/reflect/Method;" , null , null ) ; fv . visitEnd ( ) ; MethodVisitor mv = cw . visitMethod ( ACC_PRIVATE...
Create a method that can be used to intercept the calls to hasStaticInitializer made in the ObjectStreamClass . The method will ask SpringLoaded whether the type has a static initializer . SpringLoaded will be able to answer if it is a reloadable type . If it is not a reloadable type then springloaded will throw an exc...
36,744
@ SuppressWarnings ( "unused" ) private static void checkNotTheSame ( byte [ ] bs , byte [ ] bytes ) { if ( bs . length == bytes . length ) { System . out . println ( "same length!" ) ; boolean same = true ; for ( int i = 0 ; i < bs . length ; i ++ ) { if ( bs [ i ] != bytes [ i ] ) { same = false ; break ; } } if ( sa...
method useful when debugging
36,745
private void ensurePreparedForInjection ( ) { if ( ! prepared ) { try { Class < ReflectiveInterceptor > clazz = ReflectiveInterceptor . class ; method_jlcgdfs = clazz . getDeclaredMethod ( "jlClassGetDeclaredFields" , Class . class ) ; method_jlcgdf = clazz . getDeclaredMethod ( "jlClassGetDeclaredField" , Class . clas...
Cache the Method objects that will be injected .
36,746
private void ensureWatchThreadRunning ( ) { if ( ! threadRunning ) { thread = new Thread ( watchThread ) ; thread . setDaemon ( true ) ; thread . start ( ) ; watchThread . setThread ( thread ) ; watchThread . updateName ( ) ; threadRunning = true ; } }
Start the thread if it isn t already started .
36,747
public static TypeRegistry getTypeRegistryFor ( ClassLoader classloader ) { if ( classloader == null ) { return null ; } TypeRegistry existingRegistry = loaderToRegistryMap . get ( classloader ) ; if ( existingRegistry != null ) { return existingRegistry ; } if ( GlobalConfiguration . isRuntimeLogging && log . isLoggab...
Factory access method for obtaining TypeRegistry instances . Returns a TypeRegistry for the specified classloader .
36,748
private void loadPlugins ( ) { try { Enumeration < URL > pluginResources = classLoader . get ( ) . getResources ( "META-INF/services/org.springsource.reloading.agent.Plugins" ) ; while ( pluginResources . hasMoreElements ( ) ) { URL pluginResource = pluginResources . nextElement ( ) ; if ( GlobalConfiguration . isRunti...
Determine if any plugins are visible from the attached classloader
36,749
private void parseRebasePaths ( String rebaseDefinitions ) { StringTokenizer tokenizer = new StringTokenizer ( rebaseDefinitions , "," ) ; while ( tokenizer . hasMoreTokens ( ) ) { String rebasePair = tokenizer . nextToken ( ) ; int equals = rebasePair . indexOf ( '=' ) ; String fromPrefix = rebasePair . substring ( 0 ...
Process a set of rebase definitions of the form a = b c = d e = f .
36,750
public int getTypeIdFor ( String slashname , boolean allocateIfNotFound ) { if ( allocateIfNotFound ) { return NameRegistry . getIdOrAllocateFor ( slashname ) ; } else { return NameRegistry . getIdFor ( slashname ) ; } }
Lookup the type ID for a string . First checks those allocated but not yet registered then those that are already registered . If not found then a new one is allocated and recorded .
36,751
public void rememberReloadableType ( int typeId , ReloadableType rtype ) { if ( typeId >= reloadableTypes . length ) { resizeReloadableTypeArray ( typeId ) ; } reloadableTypes [ typeId ] = rtype ; if ( ( typeId + 1 ) > reloadableTypesSize ) { reloadableTypesSize = typeId + 1 ; } }
Sometimes we discover the reloadabletype during program execution for example A calls B and we haven t yet seen B . We find B has been loaded by a parent classloader let s remember B here so we can do fast lookups for it .
36,752
public ReloadableType getReloadableType ( String slashedClassName ) { int id = getTypeIdFor ( slashedClassName , true ) ; if ( id >= reloadableTypesSize ) { return null ; } return getReloadableType ( id ) ; }
Determine the reloadabletype object representation for a specified class . If the caller already knows the ID for the type that would be a quicker way to locate the reloadable type object .
36,753
public ReloadableType getReloadableType ( String slashedClassname , boolean allocateIdIfNotYetLoaded ) { if ( allocateIdIfNotYetLoaded ) { return getReloadableType ( getTypeIdFor ( slashedClassname , allocateIdIfNotYetLoaded ) ) ; } else { for ( int i = 0 ; i < reloadableTypesSize ; i ++ ) { ReloadableType rtype = relo...
Find the ReloadableType object for a given classname . If the allocateIdIfNotYetLoaded option is set then a new id will be allocated for this classname if it hasn t previously been seen before . This method does not create new ReloadableType objects they are expected to come into existence when defined by the classload...
36,754
public static Object istcheck ( int ids , String nameAndDescriptor ) { if ( TypeRegistry . nothingReloaded ) { return null ; } int registryId = ids >>> 16 ; int typeId = ids & 0xffff ; TypeRegistry typeRegistry = registryInstances [ registryId ] . get ( ) ; ReloadableType reloadableType = typeRegistry . getReloadableTy...
Determine if something has changed in a particular type related to a particular descriptor and so the dispatcher interface should be used . The type registry ID and class ID are merged in the ids parameter . This method is for INVOKESTATIC rewrites and so performs additional checks because it assumes the target is stat...
36,755
public static boolean instanceFieldInterceptionRequired ( int ids , String name ) { if ( nothingReloaded ) { return false ; } int registryId = ids >>> 16 ; int typeId = ids & 0xffff ; TypeRegistry typeRegistry = registryInstances [ registryId ] . get ( ) ; ReloadableType reloadableType = typeRegistry . getReloadableTyp...
Called for a field operation - trying to determine whether a particular field needs special handling .
36,756
public static boolean ivicheck ( int ids , String nameAndDescriptor ) { if ( nothingReloaded ) { return false ; } int registryId = ids >>> 16 ; int typeId = ids & 0xffff ; TypeRegistry typeRegistry = registryInstances [ registryId ] . get ( ) ; ReloadableType reloadableType = typeRegistry . getReloadableType ( typeId )...
Used in code the generated code replaces invokevirtual calls . Determine if the code can run as it was originally compiled .
36,757
public static ReloadableType getReloadableType ( int typeRegistryId , int typeId ) { if ( GlobalConfiguration . verboseMode && log . isLoggable ( Level . INFO ) ) { log . info ( ">TypeRegistry.getReloadableType(typeRegistryId=" + typeRegistryId + ",typeId=" + typeId + ")" ) ; } TypeRegistry typeRegistry = registryInsta...
This method discovers the reloadable type instance for the registry and type id specified .
36,758
private List < TypePattern > getPatternsFrom ( String value ) { if ( value == null ) { return Collections . emptyList ( ) ; } List < TypePattern > typePatterns = new ArrayList < TypePattern > ( ) ; StringTokenizer st = new StringTokenizer ( value , "," ) ; while ( st . hasMoreElements ( ) ) { String typepattern = st . ...
Process some type pattern objects from the supplied value . For example the value might be com . foo . Bar !com . foo . Goo
36,759
public synchronized int recordBootstrapMethod ( String slashedClassName , Handle bsm , Object [ ] bsmArgs ) { if ( bsmmap == null ) { bsmmap = new HashMap < String , BsmInfo [ ] > ( ) ; } BsmInfo [ ] bsminfo = bsmmap . get ( slashedClassName ) ; if ( bsminfo == null ) { bsminfo = new BsmInfo [ 1 ] ; bsminfo [ 0 ] = new...
When an invokedynamic instruction is reached we allocate an id that recognizes that bsm and the parameters to that bsm . The index can be used when rewriting that invokedynamic
36,760
public static void associateReloadableType ( ReloadableType child , Class < ? > parent ) { ClassLoader parentClassLoader = parent . getClassLoader ( ) ; if ( parentClassLoader == null ) { return ; } TypeRegistry parentTypeRegistry = TypeRegistry . getTypeRegistryFor ( parent . getClassLoader ( ) ) ; ReloadableType pare...
Called from the static initializer of a reloadabletype allowing it to connect itself to the parent type such that when reloading occurs we can mark all relevant types in the hierarchy as being impacted by the reload .
36,761
private void clearLocalVariableTableParameterNameDiscovererCache ( Class < ? > clazz ) { if ( localVariableTableParameterNameDiscovererInstances == null ) { return ; } if ( debug ) { System . out . println ( "SPRING_PLUGIN: ParameterNamesCache: Clearing parameter name discoverer caches" ) ; } if ( parameterNamesCacheFi...
The Spring class LocalVariableTableParameterNameDiscoverer holds a cache of parameter names discovered for members within classes and needs clearing if the class changes .
36,762
private void clearMappingRegistry ( Object o , Class < ? > clazz_AbstractHandlerMethodMapping ) { if ( debug ) { System . out . println ( "SPRING_PLUGIN: clearing out mapping registry..." ) ; } Object mappingRegistryInstance = null ; try { Field field_mappingRegistry = clazz_AbstractHandlerMethodMapping . getDeclaredFi...
the initHandlerMethods below we will get an error about already existing mappings
36,763
private static Field asSetableField ( Field field , Object target , Class < ? > valueType , Object value , boolean makeAccessibleCopy ) throws IllegalAccessException { if ( isDeleted ( field ) ) { throw Exceptions . noSuchFieldError ( field ) ; } Class < ? > clazz = field . getDeclaringClass ( ) ; int mods = field . ge...
Performs all necessary checks that need to be done before a field set should be allowed .
36,764
private static void typeCheckFieldSet ( Field field , Object value ) throws IllegalAccessException { Class < ? > fieldType = field . getType ( ) ; if ( value == null ) { if ( fieldType . isPrimitive ( ) ) { throw Exceptions . illegalSetFieldTypeException ( field , null , value ) ; } } else { if ( fieldType . isPrimitiv...
Perform a dynamic type check needed when setting a field value onto a field . Raises the appropriate exception when the check fails and returns normally otherwise . This method should only be called for object types . For primitive types call the three parameter variant instead .
36,765
private static void typeCheckFieldSet ( Field field , Class < ? > valueType , Object value ) throws IllegalAccessException { if ( ! isPrimitive ( valueType ) ) { typeCheckFieldSet ( field , value ) ; } else { Class < ? > fieldType = field . getType ( ) ; if ( ! Utils . isConvertableFrom ( fieldType , valueType ) ) { th...
Perform a dynamic type check needed when setting a field value onto a field . Raises the appropriate exception when the check fails and returns normally otherwise .
36,766
public static int jlClassGetModifiers ( Class < ? > clazz ) { ReloadableType rtype = getRType ( clazz ) ; if ( rtype == null ) { return clazz . getModifiers ( ) ; } else { return rtype . getLatestTypeDescriptor ( ) . getModifiers ( ) & ~ Opcodes . ACC_SUPER ; } }
Retrieve modifiers for a Java class which might or might not be reloadable or reloaded .
36,767
public static ReloadableType getRType ( Class < ? > clazz ) { WeakReference < ReloadableType > ref = classToRType . get ( clazz ) ; ReloadableType rtype = null ; if ( ref != null ) { rtype = ref . get ( ) ; } if ( rtype == null ) { if ( ! theOldWay ) { ClassLoader cl = clazz . getClassLoader ( ) ; TypeRegistry tr = Typ...
Access and return the ReloadableType field on a specified class .
36,768
private static Class < ? > boxTypeFor ( Class < ? > primType ) { if ( primType == int . class ) { return Integer . class ; } else if ( primType == boolean . class ) { return Boolean . class ; } else if ( primType == byte . class ) { return Byte . class ; } else if ( primType == char . class ) { return Character . class...
What s the boxed version of a given primtive type .
36,769
private byte [ ] retransform ( byte [ ] bytes ) { if ( ! determinedNeedToRetransform ) { try { String s = System . getProperty ( "insight.enabled" , "false" ) ; if ( s . equals ( "true" ) ) { ClassLoader cl = typeRegistry . getClassLoader ( ) ; Field f = cl . getClass ( ) . getSuperclass ( ) . getDeclaredField ( "weavi...
This method will attempt to apply any pre - existing transforms to the provided bytecode if it is thought to be necessary . Currently necessary is determined by finding ourselves running under tcServer and Spring Insight being turned on .
36,770
private void resetEnumRelatedState ( ) { if ( clazz == null ) { return ; } try { Field f = clazz . getClass ( ) . getDeclaredField ( "enumConstants" ) ; f . setAccessible ( true ) ; f . set ( clazz , null ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } try { Field f = clazz . getClass ( ) . getDeclaredField (...
When an enum type is reloaded two caches need to be cleared out from the Class object for the enum type .
36,771
public MethodMember getCurrentMethod ( String name , String descriptor ) { if ( liveVersion == null ) { return getMethod ( name , descriptor ) ; } else { return liveVersion . getReloadableMethod ( name , descriptor ) ; } }
Gets the method corresponding to given name and descriptor taking into consideration changes that have happened by reloading .
36,772
public int changed ( int methodId ) { if ( liveVersion == null ) { return 0 ; } else { int retval = 0 ; if ( liveVersion != null ) { if ( GlobalConfiguration . logging && log . isLoggable ( Level . FINER ) ) { log . info ( "MethodId=" + methodId + " method=" + typedescriptor . getMethod ( methodId ) ) ; } boolean b = l...
Check if the specified method is different to the original form from the type as loaded .
36,773
public __DynamicallyDispatchable determineDispatcher ( Object instance , String nameAndDescriptor ) { if ( nameAndDescriptor . startsWith ( "<init>" ) ) { if ( ! hasBeenReloaded ( ) ) { loadNewVersion ( "0" , bytesInitial ) ; } return ( __DynamicallyDispatchable ) getLiveVersion ( ) . dispatcherInstance ; } String dyna...
Intended to handle dynamic dispatch . This will determine the right type to handle the specified method and return a dispatcher that can handle it .
36,774
public FieldMember findInstanceField ( String name ) { FieldMember found = getLatestTypeDescriptor ( ) . getField ( name ) ; if ( found != null ) { return found ; } String slashedSupername = getTypeDescriptor ( ) . getSupertypeName ( ) ; ReloadableType rtype = typeRegistry . getReloadableType ( slashedSupername ) ; whi...
Find the named instance field either on this reloadable type or on a reloadable supertype - it will not go into the non - reloadable types . This method also avoids interfaces because it is looking for instance fields . This is slightly naughty but if we assume the code we are reloading is valid code it should never be...
36,775
public void setField ( Object instance , String fieldname , boolean isStatic , Object newValue ) throws IllegalAccessException { FieldReaderWriter fieldReaderWriter = locateField ( fieldname ) ; if ( isStatic && ! fieldReaderWriter . isStatic ( ) ) { throw new IncompatibleClassChangeError ( "Expected static field " + f...
Attempt to set the value of a field on an instance to the specified value .
36,776
public ReloadableType getSuperRtype ( ) { if ( superRtype != null ) { return superRtype ; } if ( superclazz == null ) { String name = this . getSlashedSupertypeName ( ) ; if ( name == null ) { return null ; } else { ReloadableType rtype = typeRegistry . getReloadableSuperType ( name ) ; superRtype = rtype ; return supe...
Return the ReloadableType representing the superclass of this type . If the supertype is not reloadable this method will return null . The ReloadableType that is returned may not be within the same type registry if the supertype was loaded by a different classloader .
36,777
public void define ( ) { staticInitializer = null ; haveLookedForStaticInitializer = false ; if ( ! typeDescriptor . isInterface ( ) ) { try { dispatcherClass = reloadableType . typeRegistry . defineClass ( dispatcherName , dispatcher , false ) ; } catch ( RuntimeException t ) { if ( t . getMessage ( ) . indexOf ( "dup...
Defines this version . Called up front but can also be called later if the ChildClassLoader in a type registry is discarded and recreated .
36,778
public MethodMember getByDescriptor ( String name , String descriptor ) { for ( MethodMember existingMethod : methods ) { if ( existingMethod . getName ( ) . equals ( name ) && existingMethod . getDescriptor ( ) . equals ( descriptor ) ) { return existingMethod ; } } return null ; }
Check if this descriptor defines a method with the specified name and descriptor . Return the method if it is found . Modifiers generic signature and exceptions are ignored in this search .
36,779
public static byte [ ] extract ( byte [ ] classbytes , TypeRegistry registry , TypeDescriptor typeDescriptor ) { return new InterfaceExtractor ( registry ) . extract ( classbytes , typeDescriptor ) ; }
Extract the fixed interface for a class and a type descriptor with more details on the methods .
36,780
public static byte [ ] createFor ( ReloadableType rtype , IncrementalTypeDescriptor newVersionTypeDescriptor , String versionstamp ) { ClassReader fileReader = new ClassReader ( rtype . interfaceBytes ) ; DispatcherBuilderVisitor dispatcherVisitor = new DispatcherBuilderVisitor ( rtype , newVersionTypeDescriptor , vers...
Factory method that builds the dispatcher for a specified reloadabletype .
36,781
public void setValue ( Object instance , Object newValue , ISMgr stateManager ) throws IllegalAccessException { if ( typeDescriptor . isReloadable ( ) ) { if ( stateManager == null ) { stateManager = findInstanceStateManager ( instance ) ; } String declaringTypeName = typeDescriptor . getName ( ) ; Map < String , Objec...
Set the value of an instance field on the specified instance to the specified value . If a state manager is passed in things can be done in a more optimal way otherwise the state manager has to be discovered from the instance .
36,782
public Object getValue ( Object instance , ISMgr stateManager ) throws IllegalAccessException , IllegalArgumentException { Object result = null ; String fieldname = theField . getName ( ) ; if ( typeDescriptor . isReloadable ( ) ) { if ( stateManager == null ) { stateManager = findInstanceStateManager ( instance ) ; } ...
Return the value of the field for which is reader - writer exists . To improve performance a fieldAccessor can be supplied but if it is missing the code will go and discover it .
36,783
private Field locateFieldByReflection ( Class < ? > clazz , String typeWanted , boolean isInterface , String name ) { if ( clazz . getName ( ) . equals ( typeWanted ) ) { Field [ ] fs = clazz . getDeclaredFields ( ) ; if ( fs != null ) { for ( Field f : fs ) { if ( f . getName ( ) . equals ( name ) ) { return f ; } } }...
Discover the named field in the hierarchy using the standard rules of resolution .
36,784
private ISMgr findInstanceStateManager ( Object instance ) { Class < ? > clazz = typeDescriptor . getReloadableType ( ) . getClazz ( ) ; try { Field fieldAccessorField = clazz . getField ( Constants . fInstanceFieldsName ) ; if ( fieldAccessorField == null ) { throw new IllegalStateException ( "Cant find field accessor...
Discover the instance state manager for the specific object instance . Will fail by exception rather than returning null .
36,785
private SSMgr findStaticStateManager ( Class < ? > clazz ) { try { Field stateManagerField = clazz . getField ( Constants . fStaticFieldsName ) ; if ( stateManagerField == null ) { throw new IllegalStateException ( "Cant find field accessor for type " + typeDescriptor . getReloadableType ( ) . getName ( ) ) ; } SSMgr s...
Discover the static state manager on the specified class and return it . Will fail by exception rather than returning null .
36,786
private Object findAndGetFieldValueInHierarchy ( Object instance ) { Class < ? > clazz = instance . getClass ( ) ; String fieldname = theField . getName ( ) ; String searchName = typeDescriptor . getName ( ) . replace ( '/' , '.' ) ; while ( clazz != null && ! clazz . getName ( ) . equals ( searchName ) ) { clazz = cla...
Walk up the instance hierarchy looking for the field and when it is found access it and return the result . Will exit via exception if it cannot find the field or something goes wrong when accessing it .
36,787
public static void addCorrectReturnInstruction ( MethodVisitor mv , ReturnType returnType , boolean createCast ) { if ( returnType . isPrimitive ( ) ) { char ch = returnType . descriptor . charAt ( 0 ) ; switch ( ch ) { case 'V' : mv . visitInsn ( RETURN ) ; break ; case 'I' : case 'Z' : case 'S' : case 'B' : case 'C' ...
Depending on the signature of the return type add the appropriate instructions to the method visitor .
36,788
public static int getParameterCount ( String methodDescriptor ) { int pos = 1 ; int count = 0 ; char ch ; while ( ( ch = methodDescriptor . charAt ( pos ) ) != ')' ) { if ( ch == 'L' ) { pos = methodDescriptor . indexOf ( ';' , pos + 1 ) ; } else if ( ch == '[' ) { while ( methodDescriptor . charAt ( ++ pos ) == '[' ) ...
Return the number of parameters in the descriptor . Copes with primitives and arrays and reference types .
36,789
public static void createLoadsBasedOnDescriptor ( MethodVisitor mv , String descriptor , int startindex ) { int slot = startindex ; int descriptorpos = 1 ; char ch ; while ( ( ch = descriptor . charAt ( descriptorpos ) ) != ')' ) { switch ( ch ) { case '[' : mv . visitVarInsn ( ALOAD , slot ) ; slot ++ ; while ( descri...
Create the set of LOAD instructions to load the method parameters . Take into account the size and type .
36,790
public static Class < ? > [ ] toParamClasses ( String methodDescriptor , ClassLoader classLoader ) throws ClassNotFoundException { Type [ ] paramTypes = Type . getArgumentTypes ( methodDescriptor ) ; Class < ? > [ ] paramClasses = new Class < ? > [ paramTypes . length ] ; for ( int i = 0 ; i < paramClasses . length ; i...
Given a method descriptor extract the parameter descriptor and convert into corresponding Class objects . This requires a reference to a class loader to convert type names into Class objects .
36,791
public static Class < ? > toClass ( Type type , ClassLoader classLoader ) throws ClassNotFoundException { switch ( type . getSort ( ) ) { case Type . VOID : return void . class ; case Type . BOOLEAN : return boolean . class ; case Type . CHAR : return char . class ; case Type . BYTE : return byte . class ; case Type . ...
Convert an asm Type into a corresponding Class object requires a reference to a ClassLoader to be able to convert classnames to class objects .
36,792
public static String toPaddedNumber ( int value , int width ) { StringBuilder s = new StringBuilder ( "00000000" ) . append ( Integer . toString ( value ) ) ; return s . substring ( s . length ( ) - width ) ; }
Create the string representation of an integer and pad it to a particular width using leading zeroes .
36,793
public static byte [ ] loadBytesFromStream ( InputStream stream ) { try { BufferedInputStream bis = new BufferedInputStream ( stream ) ; byte [ ] theData = new byte [ 10000000 ] ; int dataReadSoFar = 0 ; byte [ ] buffer = new byte [ 1024 ] ; int read = 0 ; while ( ( read = bis . read ( buffer ) ) != - 1 ) { System . ar...
Load all the byte data from an input stream .
36,794
public static int sizeOf ( String typeDescriptor ) { if ( typeDescriptor . length ( ) != 1 ) { return 1 ; } char ch = typeDescriptor . charAt ( 0 ) ; if ( ch == 'J' || ch == 'D' ) { return 2 ; } else { return 1 ; } }
Return the size of a type . The size is usually 1 except for double and long which are of size 2 . The descriptor passed in is the full descriptor including any leading L and trailing ; .
36,795
public static void dumpClass ( String file , byte [ ] bytes ) { File f = new File ( file ) ; try { FileOutputStream fos = new FileOutputStream ( f ) ; fos . write ( bytes ) ; fos . flush ( ) ; fos . close ( ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } }
Dump some bytes into the specified file .
36,796
public static int getSize ( String descriptor ) { int size = 0 ; int descriptorpos = 1 ; char ch ; while ( ( ch = descriptor . charAt ( descriptorpos ) ) != ')' ) { switch ( ch ) { case '[' : size ++ ; while ( descriptor . charAt ( ++ descriptorpos ) == '[' ) { ; } if ( descriptor . charAt ( descriptorpos ) == 'L' ) { ...
Compute the size required for a specific method descriptor .
36,797
public static byte [ ] loadFromStream ( InputStream stream ) { try { BufferedInputStream bis = new BufferedInputStream ( stream ) ; int size = 2048 ; byte [ ] theData = new byte [ size ] ; int dataReadSoFar = 0 ; byte [ ] buffer = new byte [ size / 2 ] ; int read = 0 ; while ( ( read = bis . read ( buffer ) ) != - 1 ) ...
Load the contents of an input stream .
36,798
public static < T > T [ ] arrayCopyOf ( T [ ] array , int newSize ) { @ SuppressWarnings ( "unchecked" ) T [ ] newArr = ( T [ ] ) Array . newInstance ( array . getClass ( ) . getComponentType ( ) , newSize ) ; System . arraycopy ( array , 0 , newArr , 0 , Math . min ( newSize , newArr . length ) ) ; return newArr ; }
Utility method similar to Java 1 . 6 Arrays . copyOf used instead of that method to stick to Java 1 . 5 only API .
36,799
public static int makePublicNonFinal ( int access ) { access = ( access & ~ ( ACC_PRIVATE | ACC_PROTECTED ) ) | ACC_PUBLIC ; access = ( access & ~ ACC_FINAL ) ; return access ; }
Modify visibility to be public .