avoid declararation that methods throws generic Exception
authortupshin <tupshin@tupshin.com>
Thu, 5 Feb 2004 01:01:46 +0000 (01:01 +0000)
committertupshin <tupshin@tupshin.com>
Thu, 5 Feb 2004 01:01:46 +0000 (01:01 +0000)
darcs-hash:20040205010146-a9258-c185e203455e98c1895035d10ba7dc20a133cc4b.gz

src/org/ibex/Font.java
src/org/ibex/HTTP.java
src/org/ibex/Main.java
src/org/ibex/Scheduler.java
src/org/ibex/Stream.java
src/org/ibex/XMLRPC.java
src/org/ibex/js/Lexer.java
src/org/ibex/js/Parser.java

index 2744f0e..cd1ff80 100644 (file)
@@ -3,6 +3,7 @@ package org.ibex;
 import org.xwt.translators.*;
 import org.ibex.util.*;
 import java.io.*;
+import org.ibex.js.JSExn;
 
 // FEATURE: this could be cleaner
 /** encapsulates a single font (a set of Glyphs) */
@@ -83,7 +84,7 @@ public class Font {
         if (!encounteredUnrenderedGlyph) return ((((long)width) << 32) | (long)(height & 0xffffffffL));
 
         if (callback != null) Scheduler.add(new Scheduler.Task() {
-                public void perform() throws Exception {
+                public void perform() throws IOException, JSExn {
                     // FEATURE this isn't terribly efficient... perhaps the task should go on the last glyph?
                     for(int i=0; i<text.length(); i++) {
                         Glyph g = glyphs[text.charAt(i)];
index 1463897..8242653 100644 (file)
@@ -770,7 +770,7 @@ public class HTTP {
             static public Semaphore waitingForUser = new Semaphore();
 
             public static synchronized void getPassword(final String realm, final String style,
-                                                        final String proxyIP, String oldAuth) {
+                                                        final String proxyIP, String oldAuth) throws IOException {
 
                 // this handles cases where multiple threads hit the proxy auth at the same time -- all but one will block on the
                 // synchronized keyword. If 'authorization' changed while the thread was blocked, it means that the user entered
@@ -779,7 +779,7 @@ public class HTTP {
                 if (authorization != oldAuth) return;
                 if (Log.on) Log.info(Authorization.class, "displaying proxy authorization dialog");
                 Scheduler.add(new Scheduler.Task() {
-                        public void perform() throws Exception {
+                        public void perform() throws IOException, JSExn {
                             Box b = new Box();
                             Template t = Template.buildTemplate(Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), new Ibex(null));
                             t.apply(b);
@@ -936,7 +936,7 @@ public class HTTP {
              * @return The NTLM Response.
              */
             public static byte[] getNTLMResponse(String password, byte[] challenge)
-                throws Exception {
+                throws UnsupportedEncodingException {
                 byte[] ntlmHash = ntlmHash(password);
                 return lmResponse(ntlmHash, challenge);
             }
@@ -951,7 +951,7 @@ public class HTTP {
              * @return The LM Response.
              */
             public static byte[] getLMResponse(String password, byte[] challenge)
-                throws Exception {
+                {
                 byte[] lmHash = lmHash(password);
                 return lmResponse(lmHash, challenge);
             }
@@ -973,7 +973,7 @@ public class HTTP {
              */
             public static byte[] getNTLMv2Response(String target, String user,
                                                    String password, byte[] targetInformation, byte[] challenge,
-                                                   byte[] clientChallenge) throws Exception {
+                                                   byte[] clientChallenge) throws UnsupportedEncodingException {
                 byte[] ntlmv2Hash = ntlmv2Hash(target, user, password);
                 byte[] blob = createBlob(targetInformation, clientChallenge);
                 return lmv2Response(ntlmv2Hash, blob, challenge);
@@ -994,7 +994,7 @@ public class HTTP {
              */
             public static byte[] getLMv2Response(String target, String user,
                                                  String password, byte[] challenge, byte[] clientChallenge)
-                throws Exception {
+                throws UnsupportedEncodingException {
                 byte[] ntlmv2Hash = ntlmv2Hash(target, user, password);
                 return lmv2Response(ntlmv2Hash, clientChallenge, challenge);
             }
@@ -1012,7 +1012,7 @@ public class HTTP {
              * the client challenge, null-padded to 24 bytes.
              */
             public static byte[] getNTLM2SessionResponse(String password,
-                                                         byte[] challenge, byte[] clientChallenge) throws Exception {
+                                                         byte[] challenge, byte[] clientChallenge) throws UnsupportedEncodingException {
                 byte[] ntlmHash = ntlmHash(password);
                 MD5Digest md5 = new MD5Digest();
                 md5.update(challenge, 0, challenge.length);
@@ -1032,7 +1032,7 @@ public class HTTP {
              * @return The LM Hash of the given password, used in the calculation
              * of the LM Response.
              */
-            private static byte[] lmHash(String password) throws Exception {
+            private static byte[] lmHash(String password) {
                 /*
                 byte[] oemPassword = password.toUpperCase().getBytes("US-ASCII");
                 int length = java.lang.Math.min(oemPassword.length, 14);
@@ -1062,7 +1062,7 @@ public class HTTP {
              * @return The NTLM Hash of the given password, used in the calculation
              * of the NTLM Response and the NTLMv2 and LMv2 Hashes.
              */
-            private static byte[] ntlmHash(String password) throws Exception {
+            private static byte[] ntlmHash(String password) throws UnsupportedEncodingException {
                 byte[] unicodePassword = password.getBytes("UnicodeLittleUnmarked");
                 MD4Digest md4 = new MD4Digest();
                 md4.update(unicodePassword, 0, unicodePassword.length);
@@ -1081,7 +1081,7 @@ public class HTTP {
              * and LMv2 Responses. 
              */
             private static byte[] ntlmv2Hash(String target, String user,
-                                             String password) throws Exception {
+                                             String password) throws UnsupportedEncodingException {
                 byte[] ntlmHash = ntlmHash(password);
                 String identity = user.toUpperCase() + target.toUpperCase();
                 return hmacMD5(identity.getBytes("UnicodeLittleUnmarked"), ntlmHash);
@@ -1097,7 +1097,7 @@ public class HTTP {
              * hash).
              */
             private static byte[] lmResponse(byte[] hash, byte[] challenge)
-                throws Exception {
+                {
                 /*
                 byte[] keyBytes = new byte[21];
                 System.arraycopy(hash, 0, keyBytes, 0, 16);
@@ -1132,7 +1132,7 @@ public class HTTP {
              * client data).
              */
             private static byte[] lmv2Response(byte[] hash, byte[] clientData,
-                                               byte[] challenge) throws Exception {
+                                               byte[] challenge) {
                 byte[] data = new byte[challenge.length + clientData.length];
                 System.arraycopy(challenge, 0, data, 0, challenge.length);
                 System.arraycopy(clientData, 0, data, challenge.length,
@@ -1210,7 +1210,7 @@ public class HTTP {
              *
              * @return The HMAC-MD5 hash of the given data.
              */
-            private static byte[] hmacMD5(byte[] data, byte[] key) throws Exception {
+            private static byte[] hmacMD5(byte[] data, byte[] key) {
                 byte[] ipad = new byte[64];
                 byte[] opad = new byte[64];
                 for (int i = 0; i < 64; i++) {
index 2c6a7d3..74b4b3f 100644 (file)
@@ -42,7 +42,7 @@ public class Main {
         Runtime.getRuntime().exit(-1);
     }
 
-    public static void main(String[] args) throws Exception {
+    public static void main(String[] args) throws UnknownHostException, JSExn {
         int startargs = 0;
         while (true) {
             if (startargs > args.length - 1) printUsage();
@@ -78,7 +78,7 @@ public class Main {
 
         scarImage =
             Picture.load((Stream)Main.builtin.get("org/ibex/builtin/scar.png"),
-                         new Scheduler.Task() { public void perform() throws Exception {
+                         new Scheduler.Task() { public void perform() throws JSExn, UnknownHostException {
                              ibex.resolveString(startupTemplate, false).call(new Box(), null, null, null, 1);
                          } });
 
index 43be3d9..ec8253c 100644 (file)
@@ -1,6 +1,8 @@
 // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
 package org.ibex;
 
+import java.io.IOException;
+
 import org.ibex.js.*;
 import org.ibex.util.*;
 
@@ -10,7 +12,7 @@ public class Scheduler {
     // Public API Exposed to org.ibex /////////////////////////////////////////////////
 
     private static Scheduler singleton;
-    public static interface Task { public abstract void perform() throws Exception; }
+    public static interface Task { public abstract void perform() throws IOException, JSExn; }
     public static void add(Task t) { Scheduler.runnable.append(t); }
     public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); }
 
index d200ce0..526663a 100644 (file)
@@ -117,7 +117,7 @@ public abstract class Stream extends JS.Cloneable {
                     public int read(byte[] b, int off, int len) throws IOException {
                         int ret = super.read(b, off, len);
                         if (ret != 1) bytesDownloaded += ret;
-                        Scheduler.add(new Scheduler.Task() { public void perform() throws Exception {
+                        Scheduler.add(new Scheduler.Task() { public void perform() throws IOException, JSExn {
                             callback.call(N(bytesDownloaded),
                                           N(is instanceof KnownLength ? ((KnownLength)is).getLength() : 0), null, null, 2);
                         } });
index 6c1699c..5d88d6c 100644 (file)
@@ -323,20 +323,20 @@ class XMLRPC extends JS {
             try {
                 new Helper().parse(br);
                 final Object result = fault ? new JSExn(objects.elementAt(0)) : objects.size() == 0 ? null : objects.elementAt(0);
-                Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(result); }});
+                Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(result); }});
             } finally {
                 tracker.clear();
                 objects.setSize(0);
             }
         } catch (final JSExn e) {
             final Exception e2 = e;
-            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(e2); }});
+            Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(e2); }});
         } catch (final IOException e) {
             final Exception e2 = e;
-            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(new JSExn(e2)); }});
+            Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
         } catch (final XML.Exn e) {
             final Exception e2 = e;
-            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(new JSExn(e2)); }});
+            Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
         }
     }
 }
index 6e77eb7..bf350db 100644 (file)
@@ -24,7 +24,7 @@ import java.io.*;
 class Lexer implements Tokens {
 
     /** for debugging */
-    public static void main(String[] s) throws Exception {
+    public static void main(String[] s) throws IOException {
         Lexer l = new Lexer(new InputStreamReader(System.in), "stdin", 0);
         int tok = 0;
         while((tok = l.getToken()) != -1) System.out.println(codeToString[tok]);
index 6b37917..a00f3a0 100644 (file)
@@ -72,7 +72,7 @@ class Parser extends Lexer implements ByteCodes {
     public Parser(Reader r, String sourceName, int line) throws IOException { super(r, sourceName, line); }
 
     /** for debugging */
-    public static void main(String[] s) throws Exception {
+    public static void main(String[] s) throws IOException {
         JS block = JS.fromReader("stdin", 0, new InputStreamReader(System.in));
         if (block == null) return;
         System.out.println(block);