Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Soot - a J*va Optimization Framework
   * Copyright (C) 2003 Feng Qian
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */

Simulates the native method side effects in class java.lang.ClassLoader

Author(s):
Feng Qian
<XXX>
 
 
 package soot.jimple.toolkits.pointer.nativemethods;
 
 import soot.*;
 
 public class JavaLangClassLoaderNative extends NativeMethodClass {
     public JavaLangClassLoaderNativeNativeHelper helper ) { super(helper); }

  
Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
 
   public void simulateMethod(SootMethod method,
 			     ReferenceVariable thisVar,
 			     ReferenceVariable returnVar,
 			     ReferenceVariable params[]){
 
     String subSignature = method.getSubSignature();
 
     if (subSignature.equals("java.lang.Class defineClass0(java.lang.String,byte[],int,int,java.lang.security.ProtectionDomain)")){
       java_lang_ClassLoader_defineClass0(methodthisVarreturnVarparams);
       return;
 
     } else if (subSignature.equals("java.lang.Class findBootstrapClass(java.lang.String)")){
       java_lang_ClassLoader_findBootstrapClass(methodthisVar
 					       returnVarparams);
       return;
 
     } else if (subSignature.equals("java.lang.Class findLoadedClass(java.lang.String)")){
       java_lang_ClassLoader_findLoadedClass(methodthisVar
 					    returnVarparams);
       return;
 
     } else if (subSignature.equals("java.lang.ClassLoader getCallerClassLoader()")){
       java_lang_ClassLoader_getCallerClassLoader(methodthisVar
 						 returnVarparams);
       return;
       
     } else {
       defaultMethod(methodthisVarreturnVarparams);
       return;
 
     }
   }

  
java.lang.ClassLoader ****************
   
  
Converts an array of bytes into an instance of class Class. Before the Class can be used it must be resolved. NOTE: an object representing an class object. To be conservative, the side-effect of this method will return an abstract reference points to all possible class object in current analysis environment. private native java.lang.Class defineClass0(java.lang.String, byte[], int, int, java.security.ProtectionDomain);
 
   public 
 					    ReferenceVariable thisVar,
 					    ReferenceVariable returnVar,
 					    ReferenceVariable params[]){
     .assignObjectTo(returnVar, Environment.v().getClassObject());
   }

  
NOTE: undocumented, finding the bootstrap class Assuming all classes private native java.lang.Class findBootstrapClass(java.lang.String) throws java.lang.ClassNotFoundException;
  public 
					 SootMethod method,
                                         ReferenceVariable thisVar,
					 ReferenceVariable returnVar,
					 ReferenceVariable params[]) {
    .assignObjectTo(returnVar, Environment.v().getClassObject());
  }

  
Finds the class with the given name if it had been previously loaded through this class loader. NOTE: assuming all classes. protected final native java.lang.Class findLoadedClass(java.lang.String);
  public 
					       ReferenceVariable thisVar,
					       ReferenceVariable returnVar,
					       ReferenceVariable params[]) {
    .assignObjectTo(returnVar, Environment.v().getClassObject());
  }

  
Returns a variable pointing to the only class loader static native java.lang.ClassLoader getCallerClassLoader();
  public 
				    SootMethod method,
				    ReferenceVariable thisVar,
				    ReferenceVariable returnVar,
				    ReferenceVariable params[]) {
    .assignObjectTo(returnVar, Environment.v().getClassLoaderObject());
  }

  
NO side effects. Assuming that resolving a class has not effect on the class load and class object private native void resolveClass0(java.lang.Class);
New to GrepCode? Check out our FAQ X