idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
119,200
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 .
119,201
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 .
119,202
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 .
119,203
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...
119,204
@ 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
119,205
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 .
119,206
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 .
119,207
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 .
119,208
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
119,209
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 .
119,210
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 .
119,211
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 .
119,212
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 .
119,213
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...
119,214
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...
119,215
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 .
119,216
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 .
119,217
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 .
119,218
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
119,219
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
119,220
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 .
119,221
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 .
119,222
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
119,223
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 .
119,224
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 .
119,225
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 .
119,226
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 .
119,227
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 .
119,228
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 .
119,229
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 .
119,230
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 .
119,231
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 .
119,232
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 .
119,233
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 .
119,234
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...
119,235
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 .
119,236
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 .
119,237
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 .
119,238
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 .
119,239
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 .
119,240
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 .
119,241
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 .
119,242
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 .
119,243
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 .
119,244
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 .
119,245
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 .
119,246
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 .
119,247
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 .
119,248
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 .
119,249
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 .
119,250
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 .
119,251
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 .
119,252
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 .
119,253
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 .
119,254
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 ; .
119,255
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 .
119,256
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 .
119,257
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 .
119,258
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 .
119,259
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 .
119,260
public static int insertPopsForAllParameters ( MethodVisitor mv , String desc ) { String descSequence = Utils . getParamSequence ( desc ) ; if ( descSequence == null ) { return 0 ; } int count = descSequence . length ( ) ; for ( int dpos = count - 1 ; dpos >= 0 ; dpos -- ) { char ch = descSequence . charAt ( dpos ) ; s...
Looks at the supplied descriptor and inserts enough pops to remove all parameters . Should be used when about to avoid a method call .
119,261
public static String discoverClassname ( byte [ ] classbytes ) { ClassReader cr = new ClassReader ( classbytes ) ; ClassnameDiscoveryVisitor v = new ClassnameDiscoveryVisitor ( ) ; cr . accept ( v , 0 ) ; return v . classname ; }
Discover the classname specified in the supplied bytecode and return it .
119,262
public static byte [ ] invoke ( byte [ ] bytesIn , String ... descriptors ) { ClassReader cr = new ClassReader ( bytesIn ) ; EmptyCtor ca = new EmptyCtor ( descriptors ) ; cr . accept ( ca , 0 ) ; byte [ ] newbytes = ca . getBytes ( ) ; return newbytes ; }
Empty the constructors with the specified descriptors .
119,263
public static Object emulateInvokeDynamic ( ReloadableType rtype , Class < ? > executorClass , Handle handle , Object [ ] bsmArgs , Object lookup , String indyNameAndDescriptor , Object [ ] indyParams ) { try { CallSite callsite = callLambdaMetaFactory ( rtype , bsmArgs , lookup , indyNameAndDescriptor , executorClass ...
Programmatic emulation of INVOKEDYNAMIC so initialize the callsite via use of the bootstrap method then invoke the result .
119,264
public static void main ( String [ ] args ) throws Exception { File [ ] fs = new File ( "./bin" ) . listFiles ( ) ; checkThemAll ( fs ) ; System . out . println ( "total=" + total / 1000000d ) ; }
Test entry point just goes through all the code in the bin folder
119,265
private String accessUtf8 ( int cpIndex ) { Object object = cpdata [ cpIndex ] ; if ( object instanceof String ) { return ( String ) object ; } int [ ] ptrAndLen = ( int [ ] ) object ; String value ; try { value = new String ( classbytes , ptrAndLen [ 0 ] , ptrAndLen [ 1 ] , "UTF8" ) ; } catch ( UnsupportedEncodingExce...
Return the UTF8 at the specified index in the constant pool . The data found at the constant pool for that index may not have been unpacked yet if this is the first access of the string . If not unpacked the constant pool entry is a pair of ints in an array representing the offset and length within the classbytes where...
119,266
private static void computeAnyMethodDifferences ( MethodNode oMethod , MethodNode nMethod , TypeDelta td ) { MethodDelta md = new MethodDelta ( oMethod . name , oMethod . desc ) ; if ( oMethod . access != nMethod . access ) { md . setAccessChanged ( oMethod . access , nMethod . access ) ; } InsnList oInstructions = oMe...
Determine if there any differences between the methods supplied . A MethodDelta object is built to record any differences and stored against the type delta .
119,267
public InputStream receiveFile ( ) throws SmackException , XMPPErrorException , InterruptedException { if ( inputStream != null ) { throw new IllegalStateException ( "Transfer already negotiated!" ) ; } try { inputStream = negotiateStream ( ) ; } catch ( XMPPErrorException e ) { setException ( e ) ; throw e ; } return ...
Negotiates the stream method to transfer the file over and then returns the negotiated stream .
119,268
public void receiveFile ( final File file ) throws SmackException , IOException { if ( file == null ) { throw new IllegalArgumentException ( "File cannot be null" ) ; } if ( ! file . exists ( ) ) { file . createNewFile ( ) ; } if ( ! file . canWrite ( ) ) { throw new IllegalArgumentException ( "Cannot write to provided...
This method negotiates the stream and then transfer s the file over the negotiated stream . The transferred file will be saved at the provided location .
119,269
public static AudioFormat getAudioFormat ( PayloadType payloadtype ) { switch ( payloadtype . getId ( ) ) { case 0 : return new AudioFormat ( AudioFormat . ULAW_RTP ) ; case 3 : return new AudioFormat ( AudioFormat . GSM_RTP ) ; case 4 : return new AudioFormat ( AudioFormat . G723_RTP ) ; default : return null ; } }
Return a JMF AudioFormat for a given Jingle Payload type . Return null if the payload is not supported by this jmf API .
119,270
public TransportResolver getResolver ( JingleSession session ) throws XMPPException , SmackException , InterruptedException { TransportResolver resolver = createResolver ( session ) ; if ( resolver == null ) { resolver = new BasicResolver ( ) ; } resolver . initializeAndWait ( ) ; return resolver ; }
Get a new Transport Resolver to be used in a Jingle Session .
119,271
public void setInstructions ( List < String > instructions ) { synchronized ( this . instructions ) { this . instructions . clear ( ) ; this . instructions . addAll ( instructions ) ; } }
Sets the list of instructions that explain how to fill out the form and what the form is about . The dataform could include multiple instructions since each instruction could not contain newlines characters .
119,272
public void addField ( FormField field ) { String fieldVariableName = field . getVariable ( ) ; if ( fieldVariableName != null && hasField ( fieldVariableName ) ) { throw new IllegalArgumentException ( "This data form already contains a form field with the variable name '" + fieldVariableName + "'" ) ; } synchronized (...
Adds a new field as part of the form .
119,273
public boolean addFields ( Collection < FormField > fieldsToAdd ) { boolean fieldOverridden = false ; synchronized ( fields ) { for ( FormField field : fieldsToAdd ) { FormField previousField = fields . put ( field . getVariable ( ) , field ) ; if ( previousField != null ) { fieldOverridden = true ; } } } return fieldO...
Add the given fields to this form .
119,274
public FormField getHiddenFormTypeField ( ) { FormField field = getField ( FormField . FORM_TYPE ) ; if ( field != null && field . getType ( ) == FormField . Type . hidden ) { return field ; } return null ; }
Returns the hidden FORM_TYPE field or null if this data form has none .
119,275
public void setAnswer ( String variable , int value ) { FormField field = getField ( variable ) ; if ( field == null ) { throw new IllegalArgumentException ( "Field not found for the specified variable name." ) ; } validateThatFieldIsText ( field ) ; setAnswer ( field , value ) ; }
Sets a new int value to a given form s field . The field whose variable matches the requested variable will be completed with the specified value . If no field could be found for the specified variable then an exception will be raised .
119,276
public void setAnswer ( String variable , boolean value ) { FormField field = getField ( variable ) ; if ( field == null ) { throw new IllegalArgumentException ( "Field not found for the specified variable name." ) ; } if ( field . getType ( ) != FormField . Type . bool ) { throw new IllegalArgumentException ( "This fi...
Sets a new boolean value to a given form s field . The field whose variable matches the requested variable will be completed with the specified value . If no field could be found for the specified variable then an exception will be raised .
119,277
public void setDefaultAnswer ( String variable ) { if ( ! isSubmitType ( ) ) { throw new IllegalStateException ( "Cannot set an answer if the form is not of type " + "\"submit\"" ) ; } FormField field = getField ( variable ) ; if ( field != null ) { field . resetValues ( ) ; for ( CharSequence value : field . getValues...
Sets the default value as the value of a given form s field . The field whose variable matches the requested variable will be completed with its default value . If no field could be found for the specified variable then an exception will be raised .
119,278
public String getInstructions ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( Iterator < String > it = dataForm . getInstructions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { sb . append ( it . next ( ) ) ; if ( it . hasNext ( ) ) { sb . append ( '\n' ) ; } } return sb . toString ( ) ; }
Returns the instructions that explain how to fill out the form and what the form is about .
119,279
public void setInstructions ( String instructions ) { ArrayList < String > instructionsList = new ArrayList < > ( ) ; StringTokenizer st = new StringTokenizer ( instructions , "\n" ) ; while ( st . hasMoreTokens ( ) ) { instructionsList . add ( st . nextToken ( ) ) ; } dataForm . setInstructions ( instructionsList ) ; ...
Sets instructions that explain how to fill out the form and what the form is about .
119,280
public synchronized void enable ( ) { ServiceDiscoveryManager . getInstanceFor ( connection ( ) ) . addFeature ( NAMESPACE ) ; StanzaFilter filter = new AndFilter ( OUTGOING_FILTER , new NotFilter ( OUTGOING_FILTER ) ) ; connection ( ) . addStanzaInterceptor ( ADD_ORIGIN_ID_INTERCEPTOR , filter ) ; }
Start appending origin - id elements to outgoing stanzas and add the feature to disco .
119,281
public void addPayloadType ( final PayloadType pt ) { synchronized ( payloads ) { if ( pt == null ) { LOGGER . severe ( "Null payload type" ) ; } else { payloads . add ( pt ) ; } } }
Adds a audio payload type to the packet .
119,282
public String [ ] getGroupArrayNames ( ) { synchronized ( groupNames ) { return Collections . unmodifiableList ( groupNames ) . toArray ( new String [ groupNames . size ( ) ] ) ; } }
Returns a String array for the group names that the roster entry belongs to .
119,283
public static synchronized ChatStateManager getInstance ( final XMPPConnection connection ) { ChatStateManager manager = INSTANCES . get ( connection ) ; if ( manager == null ) { manager = new ChatStateManager ( connection ) ; INSTANCES . put ( connection , manager ) ; } return manager ; }
Returns the ChatStateManager related to the XMPPConnection and it will create one if it does not yet exist .
119,284
public static synchronized MultiUserChatManager getInstanceFor ( XMPPConnection connection ) { MultiUserChatManager multiUserChatManager = INSTANCES . get ( connection ) ; if ( multiUserChatManager == null ) { multiUserChatManager = new MultiUserChatManager ( connection ) ; INSTANCES . put ( connection , multiUserChatM...
Get a instance of a multi user chat manager for the given connection .
119,285
public boolean isServiceEnabled ( Jid user ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return serviceDiscoveryManager . supportsFeature ( user , MUCInitialPresence . NAMESPACE ) ; }
Returns true if the specified user supports the Multi - User Chat protocol .
119,286
public RoomInfo getRoomInfo ( EntityBareJid room ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { DiscoverInfo info = serviceDiscoveryManager . discoverInfo ( room ) ; return new RoomInfo ( info ) ; }
Returns the discovered information of a given room without actually having to join the room . The server will provide information only for rooms that are public .
119,287
public List < DomainBareJid > getMucServiceDomains ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return serviceDiscoveryManager . findServices ( MUCInitialPresence . NAMESPACE , false , false ) ; }
Returns a collection with the XMPP addresses of the Multi - User Chat services .
119,288
public boolean providesMucService ( DomainBareJid domainBareJid ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return serviceDiscoveryManager . supportsFeature ( domainBareJid , MUCInitialPresence . NAMESPACE ) ; }
Check if the provided domain bare JID provides a MUC service .
119,289
public Map < EntityBareJid , HostedRoom > getRoomsHostedBy ( DomainBareJid serviceName ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotAMucServiceException { if ( ! providesMucService ( serviceName ) ) { throw new NotAMucServiceException ( serviceName ) ; } Discover...
Returns a Map of HostedRooms where each HostedRoom has the XMPP address of the room and the room s name . Once discovered the rooms hosted by a chat service it is possible to discover more detailed room information or join the room .
119,290
public void decline ( EntityBareJid room , EntityBareJid inviter , String reason ) throws NotConnectedException , InterruptedException { Message message = new Message ( room ) ; MUCUser mucUser = new MUCUser ( ) ; MUCUser . Decline decline = new MUCUser . Decline ( reason , inviter ) ; mucUser . setDecline ( decline ) ...
Informs the sender of an invitation that the invitee declines the invitation . The rejection will be sent to the room which in turn will forward the rejection to the inviter .
119,291
public final void challengeReceived ( String challengeString , boolean finalChallenge ) throws SmackSaslException , InterruptedException , NotConnectedException { byte [ ] challenge = Base64 . decode ( ( challengeString != null && challengeString . equals ( "=" ) ) ? "" : challengeString ) ; byte [ ] response = evaluat...
The server is challenging the SASL mechanism for the stanza he just sent . Send a response to the server s challenge .
119,292
public VCard loadVCard ( EntityBareJid bareJid ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { VCard vcardRequest = new VCard ( ) ; vcardRequest . setTo ( bareJid ) ; VCard result = connection ( ) . createStanzaCollectorAndSend ( vcardRequest ) . nextResultOrThrow ( ) ...
Load VCard information for a given user .
119,293
public static void setDebuggerClass ( Class < ? extends SmackDebugger > debuggerClass ) { if ( debuggerClass == null ) { System . clearProperty ( DEBUGGER_CLASS_PROPERTY_NAME ) ; } else { System . setProperty ( DEBUGGER_CLASS_PROPERTY_NAME , debuggerClass . getCanonicalName ( ) ) ; } }
Sets custom debugger class to be created by this factory .
119,294
@ SuppressWarnings ( "unchecked" ) public static Class < SmackDebugger > getDebuggerClass ( ) { String customDebuggerClassName = getCustomDebuggerClassName ( ) ; if ( customDebuggerClassName == null ) { return getOneOfDefaultDebuggerClasses ( ) ; } else { try { return ( Class < SmackDebugger > ) Class . forName ( custo...
Returns debugger class used by this factory .
119,295
public static final String replace ( String string , String oldString , String newString ) { if ( string == null ) { return null ; } if ( newString == null ) { return string ; } int i = 0 ; if ( ( i = string . indexOf ( oldString , i ) ) >= 0 ) { char [ ] string2 = string . toCharArray ( ) ; char [ ] newString2 = newSt...
Replaces all instances of oldString with newString in string .
119,296
public void send ( Roster roster , Jid targetUserID ) throws NotConnectedException , InterruptedException { Message msg = new Message ( targetUserID ) ; RosterExchange rosterExchange = new RosterExchange ( roster ) ; msg . addExtension ( rosterExchange ) ; XMPPConnection connection = weakRefConnection . get ( ) ; conne...
Sends a roster to userID . All the entries of the roster will be sent to the target user .
119,297
public void send ( RosterEntry rosterEntry , Jid targetUserID ) throws NotConnectedException , InterruptedException { Message msg = new Message ( targetUserID ) ; RosterExchange rosterExchange = new RosterExchange ( ) ; rosterExchange . addRosterEntry ( rosterEntry ) ; msg . addExtension ( rosterExchange ) ; XMPPConnec...
Sends a roster entry to userID .
119,298
public void send ( RosterGroup rosterGroup , Jid targetUserID ) throws NotConnectedException , InterruptedException { Message msg = new Message ( targetUserID ) ; RosterExchange rosterExchange = new RosterExchange ( ) ; for ( RosterEntry entry : rosterGroup . getEntries ( ) ) { rosterExchange . addRosterEntry ( entry )...
Sends a roster group to userID . All the entries of the group will be sent to the target user .
119,299
private void fireRosterExchangeListeners ( Jid from , Iterator < RemoteRosterEntry > remoteRosterEntries ) { RosterExchangeListener [ ] listeners ; synchronized ( rosterExchangeListeners ) { listeners = new RosterExchangeListener [ rosterExchangeListeners . size ( ) ] ; rosterExchangeListeners . toArray ( listeners ) ;...
Fires roster exchange listeners .