gpt4 book ai didi

com.ibm.wala.properties.WalaProperties类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 23:31:05 26 4
gpt4 key购买 nike

本文整理了Java中com.ibm.wala.properties.WalaProperties类的一些代码示例,展示了WalaProperties类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WalaProperties类的具体详情如下:
包路径:com.ibm.wala.properties.WalaProperties
类名称:WalaProperties

WalaProperties介绍

暂无

代码示例

代码示例来源:origin: wala/WALA

public static <T, P, F> void viewIFDS(TabulationResult<T, P, F> r, Collection<? extends P> roots, NodeDecorator<T> labels)
  throws WalaException {
 Properties p = null;
 try {
  p = WalaProperties.loadProperties();
 } catch (WalaException e) {
  e.printStackTrace();
  Assertions.UNREACHABLE();
 }
 String scratch = p.getProperty(WalaProperties.OUTPUT_DIR);
 viewIFDS(r, roots, labels, scratch);
}

代码示例来源:origin: wala/WALA

public static Properties loadProperties() throws WalaException {
  try {
   Properties result = loadPropertiesFromFile(WalaProperties.class.getClassLoader(), PROPERTY_FILENAME);

   String outputDir = result.getProperty(OUTPUT_DIR, DefaultPropertiesValues.DEFAULT_OUTPUT_DIR);
   result.setProperty(OUTPUT_DIR, convertToAbsolute(outputDir));

   String walaReport = result.getProperty(WALA_REPORT, DefaultPropertiesValues.DEFAULT_WALA_REPORT_FILENAME);
   result.setProperty(WALA_REPORT, convertToAbsolute(walaReport));

   return result;
  } catch (Exception e) {
//      e.printStackTrace();
   throw new WalaException("Unable to set up wala properties ", e);
  }
 }

代码示例来源:origin: wala/WALA

/**
 * @return names of the Jar files holding J2EE libraries
 * @throws IllegalStateException if the J2EE_DIR property is not set
 */
public static String[] getJ2EEJarFiles() {
 Properties p = null;
 try {
  p = WalaProperties.loadProperties();
 } catch (WalaException e) {
  e.printStackTrace();
  throw new IllegalStateException("problem loading wala.properties");
 }
 String dir = p.getProperty(WalaProperties.J2EE_DIR);
 if (dir == null) {
  throw new IllegalStateException("No J2EE directory specified");
 }
 return getJarsInDirectory(dir);
}

代码示例来源:origin: wala/WALA

protected void instrument(String testJarLocation) throws IOException, ClassNotFoundException, InvalidClassFileException, FailureException {
 if (! instrumentedJarBuilt) {
  System.err.println("core data jar to instrument: " + testJarLocation);
  
  Files.deleteIfExists(instrumentedJarLocation);
  
  String rtJar = null;
  for(String jar : WalaProperties.getJ2SEJarFiles()) {
   if (jar.endsWith(File.separator + "rt.jar") || jar.endsWith(File.separator + "classes.jar")) {
    rtJar = jar;
   }
  }
  List<String> args = new ArrayList<>(Arrays.asList(testJarLocation, "-o", instrumentedJarLocation.toString()));
  if (rtJar != null) {
   args.addAll(Arrays.asList("--rt-jar", rtJar));
  }
  if (testPatchCalls) {
   args.add("--patch-calls");
  }
  OfflineDynamicCallGraph.main(args.toArray(new String[0]));
  Assert.assertTrue("expected to create " + instrumentedJarLocation, Files.exists(instrumentedJarLocation));
  instrumentedJarBuilt = true;
 }
}

代码示例来源:origin: wala/WALA

public static Properties loadProperties()  {
 try {
  Properties result = WalaProperties.loadPropertiesFromFile(WalaExamplesProperties.class.getClassLoader(), PROPERTY_FILENAME);
  return result;
 } catch (Exception e) {
  e.printStackTrace();
  throw new IllegalStateException("Unable to set up wala examples properties ", e);
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

static String convertToAbsolute(String path) {
 final File file = new File(path);
 return (file.isAbsolute()) ? file.getAbsolutePath() : WalaProperties.getWalaHomeDir().concat(File.separator).concat(path);
}

代码示例来源:origin: wala/WALA

public static Properties loadPropertiesFromFile(ClassLoader loader, String fileName) throws IOException {
 if (loader == null) {
  throw new IllegalArgumentException("loader is null");
 }
 if (fileName == null) {
  throw new IllegalArgumentException("null fileName");
 }
 try (final InputStream propertyStream = loader.getResourceAsStream(fileName)) {
  if (propertyStream == null) {
   // create default properties
   Properties defprop = new Properties();
   defprop.setProperty(OUTPUT_DIR, "./out");
   defprop.setProperty(INPUT_DIR, "./in");
   defprop.setProperty(ECLIPSE_PLUGINS_DIR, "./plugins");
   defprop.setProperty(WALA_REPORT, "./wala_report.txt");
   defprop.setProperty(J2EE_DIR, "./j2ee");
   final String j2selib = guessJavaLib();
   defprop.setProperty(J2SE_DIR, j2selib);
   return defprop;
  }
  Properties result = new Properties();
  result.load(propertyStream);
  if (!result.containsKey(J2SE_DIR)) {
   final String j2selib = guessJavaLib();
   result.setProperty(J2SE_DIR, j2selib);
  }
  return result;
 }
}

代码示例来源:origin: wala/WALA

scope.setLoaderImpl(walaLoader, entryPathname);
} else if ("stdlib".equals(entryType)) {
 String[] stdlibs = WalaProperties.getJ2SEJarFiles();
 for (String stdlib : stdlibs) {
  scope.addToScope(walaLoader, new JarFile(stdlib, false));

代码示例来源:origin: wala/WALA

static String convertToAbsolute(String path) {
 final File file = new File(path);
 return (file.isAbsolute()) ? file.getAbsolutePath() : WalaProperties.getWalaHomeDir().concat(File.separator).concat(path);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

public static Properties loadPropertiesFromFile(ClassLoader loader, String fileName) throws IOException {
 if (loader == null) {
  throw new IllegalArgumentException("loader is null");
 }
 if (fileName == null) {
  throw new IllegalArgumentException("null fileName");
 }
 try (final InputStream propertyStream = loader.getResourceAsStream(fileName)) {
  if (propertyStream == null) {
   // create default properties
   Properties defprop = new Properties();
   defprop.setProperty(OUTPUT_DIR, "./out");
   defprop.setProperty(INPUT_DIR, "./in");
   defprop.setProperty(ECLIPSE_PLUGINS_DIR, "./plugins");
   defprop.setProperty(WALA_REPORT, "./wala_report.txt");
   defprop.setProperty(J2EE_DIR, "./j2ee");
   final String j2selib = guessJavaLib();
   defprop.setProperty(J2SE_DIR, j2selib);
   return defprop;
  }
  Properties result = new Properties();
  result.load(propertyStream);
  if (!result.containsKey(J2SE_DIR)) {
   final String j2selib = guessJavaLib();
   result.setProperty(J2SE_DIR, j2selib);
  }
  return result;
 }
}

代码示例来源:origin: wala/WALA

public static void main(String[] args) throws IllegalArgumentException, CancelException, IOException {
 try {
  Properties p = new Properties();
  p.putAll(WalaProperties.loadProperties());
 } catch (WalaException e) {
  e.printStackTrace();
  Assertions.UNREACHABLE();
 }
 runTestCase(TestConstants.JLEX_MAIN, TestConstants.JLEX, "JLex");
 // runTestCase(TestConstants.HELLO_MAIN, TestConstants.HELLO, "Hello");
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

/**
 * @return names of the Jar files holding J2EE libraries
 * @throws IllegalStateException if the J2EE_DIR property is not set
 */
public static String[] getJ2EEJarFiles() {
 Properties p = null;
 try {
  p = WalaProperties.loadProperties();
 } catch (WalaException e) {
  e.printStackTrace();
  throw new IllegalStateException("problem loading wala.properties");
 }
 String dir = p.getProperty(WalaProperties.J2EE_DIR);
 if (dir == null) {
  throw new IllegalStateException("No J2EE directory specified");
 }
 return getJarsInDirectory(dir);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

scope.setLoaderImpl(walaLoader, entryPathname);
} else if ("stdlib".equals(entryType)) {
 String[] stdlibs = WalaProperties.getJ2SEJarFiles();
 for (String stdlib : stdlibs) {
  scope.addToScope(walaLoader, new JarFile(stdlib, false));

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

public static Properties loadProperties() throws WalaException {
  try {
   Properties result = loadPropertiesFromFile(WalaProperties.class.getClassLoader(), PROPERTY_FILENAME);

   String outputDir = result.getProperty(OUTPUT_DIR, DefaultPropertiesValues.DEFAULT_OUTPUT_DIR);
   result.setProperty(OUTPUT_DIR, convertToAbsolute(outputDir));

   String walaReport = result.getProperty(WALA_REPORT, DefaultPropertiesValues.DEFAULT_WALA_REPORT_FILENAME);
   result.setProperty(WALA_REPORT, convertToAbsolute(walaReport));

   return result;
  } catch (Exception e) {
//      e.printStackTrace();
   throw new WalaException("Unable to set up wala properties ", e);
  }
 }

代码示例来源:origin: wala/WALA

/**
 * Collect the set of JarFiles that constitute the system libraries of the running JRE.
 */
private JarFile[] getSystemJars() throws IOException {
 String javaHomePath = "garbage";
 Set<JarFile> jarFiles = HashSetFactory.make();
 // first, see if wala.properties has been set up
 try {
  Properties p = WalaProperties.loadProperties();
  javaHomePath = p.getProperty(WalaProperties.J2SE_DIR);
 } catch (WalaException e) {
  // no luck.
 }
 // if not, try assuming the running JRE looks normal
 File x = new File(javaHomePath);
 if (!(x.exists() && x.isDirectory())) {
  javaHomePath = System.getProperty("java.home");
  if (!javaHomePath.endsWith(File.separator)) {
   javaHomePath = javaHomePath + File.separator;
  }
  javaHomePath = javaHomePath + "lib";
 }
 // find jars from chosen JRE lib path
 collectJars(new File(javaHomePath), jarFiles);
 return jarFiles.toArray(new JarFile[0]);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

/**
 * Determine the classpath noted in wala.properties for J2SE standard libraries
 * 
 * If wala.properties cannot be loaded, returns jar files in boot classpath.
 * @throws IllegalStateException if jar files cannot be discovered
 * @see PlatformUtil#getBootClassPathJars() 
 */
public static String[] getJ2SEJarFiles() {
 Properties p = null;
 try {
  p = WalaProperties.loadProperties();
 } catch (WalaException e) {
  return PlatformUtil.getBootClassPathJars();
 }
 String dir = p.getProperty(WalaProperties.J2SE_DIR);
 if (dir == null || !(new File(dir)).isDirectory()) {
  System.err.println("WARNING: java_runtime_dir " + dir + " in wala.properties is invalid.  Using boot class path instead.");
  return PlatformUtil.getBootClassPathJars();      
 }
 return getJarsInDirectory(dir);
}

代码示例来源:origin: wala/WALA

AnalysisScope scope = new JavaSourceAnalysisScope();
String[] stdlibs = WalaProperties.getJ2SEJarFiles();
for (String stdlib : stdlibs) {
 scope.addToScope(ClassLoaderReference.Primordial, new JarFile(stdlib));

代码示例来源:origin: wala/WALA

/**
 * @param appJar something like "c:/temp/testdata/java_cup.jar"
 */
public static Process run(String appJar, String exclusionFile) throws IllegalArgumentException, CancelException {
 try {
  Graph<CGNode> g = buildPrunedCallGraph(appJar, (new FileProvider()).getFile(exclusionFile));
  Properties p = null;
  try {
   p = WalaExamplesProperties.loadProperties();
   p.putAll(WalaProperties.loadProperties());
  } catch (WalaException e) {
   e.printStackTrace();
   Assertions.UNREACHABLE();
  }
  String pdfFile = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + PDF_FILE;
  String dotExe = p.getProperty(WalaExamplesProperties.DOT_EXE);
  DotUtil.dotify(g, null, PDFTypeHierarchy.DOT_FILE, pdfFile, dotExe);
  String gvExe = p.getProperty(WalaExamplesProperties.PDFVIEW_EXE);
  return PDFViewUtil.launchPDFView(pdfFile, gvExe);
 } catch (WalaException e) {
  e.printStackTrace();
  return null;
 } catch (IOException e) {
  e.printStackTrace();
  return null;
 }
}

代码示例来源:origin: wala/WALA

/**
 * Determine the classpath noted in wala.properties for J2SE standard libraries
 * 
 * If wala.properties cannot be loaded, returns jar files in boot classpath.
 * @throws IllegalStateException if jar files cannot be discovered
 * @see PlatformUtil#getBootClassPathJars() 
 */
public static String[] getJ2SEJarFiles() {
 Properties p = null;
 try {
  p = WalaProperties.loadProperties();
 } catch (WalaException e) {
  return PlatformUtil.getBootClassPathJars();
 }
 String dir = p.getProperty(WalaProperties.J2SE_DIR);
 if (dir == null || !(new File(dir)).isDirectory()) {
  System.err.println("WARNING: java_runtime_dir " + dir + " in wala.properties is invalid.  Using boot class path instead.");
  return PlatformUtil.getBootClassPathJars();      
 }
 return getJarsInDirectory(dir);
}

代码示例来源:origin: wala/WALA

wp = WalaProperties.loadProperties();
 wp.putAll(WalaExamplesProperties.loadProperties());
} catch (WalaException e) {

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com