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
  * 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.

A wrapper for native method side-effect simulation. The caller passes in a native method with parameters, the corresponding native simulator gets called.

Feng Qian
 package soot.jimple.toolkits.pointer.util;
 import soot.*;
 import java.util.*;
 public class NativeMethodDriver {
     public NativeMethodDriverNativeHelper helper ) {
         .put("java.lang.Object"new JavaLangObjectNative(helper));
         .put("java.lang.System"new JavaLangSystemNative(helper));
         .put("java.lang.Runtime"new JavaLangRuntimeNative(helper));
         .put("java.lang.Shutdown"new JavaLangShutdownNative(helper));
         .put("java.lang.String"new JavaLangStringNative(helper));
         .put("java.lang.Float"new JavaLangFloatNative(helper));
         .put("java.lang.Double"new JavaLangDoubleNative(helper));
         .put("java.lang.StrictMath"new JavaLangStrictMathNative(helper));
         .put("java.lang.Throwable"new JavaLangThrowableNative(helper));
         .put("java.lang.Class"new JavaLangClassNative(helper));
         .put("java.lang.Package"new JavaLangPackageNative(helper));
         .put("java.lang.Thread"new JavaLangThreadNative(helper));
         .put("java.lang.ClassLoader"new JavaLangClassLoaderNative(helper));
                        new JavaLangClassLoaderNativeLibraryNative(helper));
                        new JavaLangSecurityManagerNative(helper));
                        new JavaLangReflectFieldNative(helper));
                        new JavaLangReflectArrayNative(helper));
                        new JavaLangReflectMethodNative(helper));
                        new JavaLangReflectConstructorNative(helper));
                        new JavaLangReflectProxyNative(helper));
                        new JavaIoFileInputStreamNative(helper));
                        new JavaIoFileOutputStreamNative(helper));
                        new JavaIoObjectInputStreamNative(helper));
                        new JavaIoObjectOutputStreamNative(helper));
                        new JavaIoObjectStreamClassNative(helper));
         .put(""new JavaIoFileSystemNative(helper));
         .put(""new JavaIoFileDescriptorNative(helper));
                        new JavaUtilResourceBundleNative(helper));
         .put("java.util.TimeZone"new JavaUtilTimeZoneNative(helper));
                        new JavaUtilJarJarFileNative(helper));
                        new JavaUtilZipCRC32Native(helper));
                        new JavaUtilZipInflaterNative(helper));
                        new JavaUtilZipZipFileNative(helper));
                        new JavaUtilZipZipEntryNative(helper));
                       new JavaSecurityAccessControllerNative(helper));
                       new JavaNetInetAddressNative(helper));
                       new JavaNetInetAddressImplNative(helper));
                       new SunMiscSignalNative(helper));
                       new SunMiscSignalHandlerNative(helper));
                       new SunMiscUnsafeNative(helper));
  private final boolean DEBUG = false;

The entry point of native method simulation.

method, must be a native method
thisVar, the variable represent @this, it can be null if the method is static
returnVar, the variable represent @return it is null if the method has no return
params, array of parameters.
  public boolean process(SootMethod method
				ReferenceVariable params[]) {
    String cname = method.getDeclaringClass().getName();
    NativeMethodClass clsSim = .get(cname);
//    G.v().out.println(method.toString());
    if (clsSim == null) {
	  //G.v().out.println("WARNING: it is unsafe to simulate the method ");
	  //G.v().out.println("         "+method.toString());	
      //throw new NativeMethodNotSupportedException(method);
      return true;
    } else {
      try {
      } catch (NativeMethodNotSupportedException e) {
          if() {
              G.v()..println("WARNING: it is unsafe to simulate the method ");
              G.v()..println("         "+method.toString());	
      return true;
New to GrepCode? Check out our FAQ X