From 775557f17896b3823d917f0205d08b1e92576d1b Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 17 Dec 2023 15:28:20 -0800 Subject: [PATCH] remove deprecated calls --- .../test/FieldBasedCGGamesTest.java | 29 +++++++++++++------ .../fieldbased/test/FieldBasedJQueryTest.java | 8 +++-- .../cast/js/rhino/test/HTMLCGBuilder.java | 8 +++-- .../ibm/wala/cast/js/vis/JsViewerDriver.java | 7 +++-- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedCGGamesTest.java b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedCGGamesTest.java index 1f62fa683d..fe4424b8e0 100644 --- a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedCGGamesTest.java +++ b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedCGGamesTest.java @@ -5,6 +5,9 @@ import com.ibm.wala.util.CancelException; import com.ibm.wala.util.WalaException; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; @@ -15,21 +18,29 @@ public class FieldBasedCGGamesTest extends AbstractFieldBasedTest { @Test public void testBunnyHunt() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.themaninblue.com/experiment/BunnyHunt/"); + URL url = getUrl("http://www.themaninblue.com/experiment/BunnyHunt/"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC); } + private static URL getUrl(String urlStr) throws MalformedURLException { + try { + return new URI(urlStr).toURL(); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + @Disabled("seems to break with http issues") @Test public void testBeslimed() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.markus-inger.de/test/game.php"); + URL url = getUrl("http://www.markus-inger.de/test/game.php"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC); } @Disabled("seems to break with http issues") @Test public void testDiggAttack() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.pixastic.com/labs/digg_attack/"); + URL url = getUrl("http://www.pixastic.com/labs/digg_attack/"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC); } @@ -37,7 +48,7 @@ public void testDiggAttack() throws IOException, WalaException, Error, CancelExc @Test public void testRiverRaider() throws IOException, WalaException, Error, CancelException { URL url = - new URL( + getUrl( "http://playstar.mobi/games/riverraider/index.html?playerId=&gameId=8&highscore=102425"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST); } @@ -45,31 +56,31 @@ public void testRiverRaider() throws IOException, WalaException, Error, CancelEx @Disabled("fails with \"timed out\" CancelException") @Test public void testSolitaire() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.inmensia.com/files/solitaire1.0.html"); + URL url = getUrl("http://www.inmensia.com/files/solitaire1.0.html"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC); } @Test // (expected = CancelException.class) public void testWorldOfSolitaire() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://worldofsolitaire.com/"); + URL url = getUrl("http://worldofsolitaire.com/"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC); } @Test public void testMinesweeper() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.inmensia.com/files/minesweeper1.0.html"); + URL url = getUrl("http://www.inmensia.com/files/minesweeper1.0.html"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST); } @Test public void testProtoRPG() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.protorpg.com/games/protorpg/?game=prologue"); + URL url = getUrl("http://www.protorpg.com/games/protorpg/?game=prologue"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST); } @Test public void testBattleship() throws IOException, WalaException, Error, CancelException { - URL url = new URL("http://www.sinkmyship.com/battleship/single.html"); + URL url = getUrl("http://www.sinkmyship.com/battleship/single.html"); runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST); } } diff --git a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedJQueryTest.java b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedJQueryTest.java index 898a96ac7d..ed999afbff 100644 --- a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedJQueryTest.java +++ b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/callgraph/fieldbased/test/FieldBasedJQueryTest.java @@ -5,7 +5,8 @@ import com.ibm.wala.util.CancelException; import com.ibm.wala.util.WalaException; import java.io.IOException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -13,9 +14,10 @@ public class FieldBasedJQueryTest extends AbstractFieldBasedTest { @Test - public void test1_8_2() throws IOException, WalaException, Error, CancelException { + public void test1_8_2() + throws IOException, WalaException, Error, CancelException, URISyntaxException { runTest( - new URL("http://code.jquery.com/jquery-1.8.2.js"), + new URI("http://code.jquery.com/jquery-1.8.2.js").toURL(), new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST); } diff --git a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java index 8fdb6e260f..a3e6e4bb72 100644 --- a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java +++ b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java @@ -35,6 +35,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Properties; import java.util.function.Supplier; @@ -78,7 +80,7 @@ public static CGBuilderResult buildHTMLCG( URL url = null; try { url = toUrl(src); - } catch (MalformedURLException e1) { + } catch (MalformedURLException | URISyntaxException e1) { fail("Could not find page to analyse: " + src); } com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory( @@ -118,7 +120,7 @@ public static CGBuilderResult buildHTMLCG( } } - private static URL toUrl(String src) throws MalformedURLException { + private static URL toUrl(String src) throws MalformedURLException, URISyntaxException { // first try interpreting as local file name, if that doesn't work just // assume it's a URL try { @@ -126,7 +128,7 @@ private static URL toUrl(String src) throws MalformedURLException { URL url = f.toURI().toURL(); return url; } catch (FileNotFoundException fnfe) { - return new URL(src); + return new URI(src).toURL(); } } diff --git a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/vis/JsViewerDriver.java b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/vis/JsViewerDriver.java index 8739b8218e..85edcff89a 100644 --- a/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/vis/JsViewerDriver.java +++ b/cast/js/rhino/src/test/java/com/ibm/wala/cast/js/vis/JsViewerDriver.java @@ -34,6 +34,8 @@ import com.ibm.wala.util.CancelException; import com.ibm.wala.util.WalaException; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Set; @@ -44,7 +46,8 @@ public static void main(String args[]) IOException, CancelException, Error, - WalaException { + WalaException, + URISyntaxException { if (args.length != 1) { System.out.println("Usage: "); @@ -52,7 +55,7 @@ public static void main(String args[]) } boolean domless = false; - URL url = new URL(args[0]); + URL url = new URI(args[0]).toURL(); // computing CG + PA JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());