2006-11-22 17:45:24 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*******************************************************************************/
|
|
|
|
package com.ibm.wala.core.tests.callGraph;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import com.ibm.wala.core.tests.util.TestConstants;
|
|
|
|
import com.ibm.wala.core.tests.util.WalaTestCase;
|
|
|
|
import com.ibm.wala.ecore.java.impl.JavaPackageImpl;
|
|
|
|
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
|
|
|
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
2007-05-15 17:44:54 +00:00
|
|
|
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
2006-11-22 17:45:24 +00:00
|
|
|
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
|
|
|
import com.ibm.wala.util.warnings.WalaException;
|
|
|
|
import com.ibm.wala.util.warnings.Warning;
|
2007-07-06 22:07:24 +00:00
|
|
|
import com.ibm.wala.util.warnings.Warnings;
|
2006-11-22 17:45:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Tests for Call Graph construction
|
|
|
|
*
|
|
|
|
* @author sfink
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class ReflectionTest extends WalaTestCase {
|
|
|
|
|
|
|
|
static {
|
|
|
|
JavaPackageImpl.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
justThisTest(ReflectionTest.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testReflect1() throws WalaException {
|
|
|
|
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
|
2007-07-06 22:07:24 +00:00
|
|
|
ClassHierarchy cha = ClassHierarchy.make(scope);
|
2007-05-15 17:44:54 +00:00
|
|
|
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.REFLECT1_MAIN);
|
2006-11-22 17:45:24 +00:00
|
|
|
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
|
|
|
|
2007-07-06 22:07:24 +00:00
|
|
|
Warnings.clear();
|
|
|
|
CallGraphTest.doCallGraphs(options, cha, scope, null, useShortProfile(), false);
|
|
|
|
for (Iterator<Warning> it = Warnings.iterator(); it.hasNext(); ) {
|
2006-11-22 17:45:24 +00:00
|
|
|
Warning w = (Warning)it.next();
|
|
|
|
if (w.toString().indexOf("com/ibm/jvm") > 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-01-15 18:30:33 +00:00
|
|
|
if (w.toString().indexOf("Integer") >= 0) {
|
|
|
|
assertTrue(w.toString(), false);
|
|
|
|
}
|
2006-11-22 17:45:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|