diff options
author | Rich Hickey <richhickey@gmail.com> | 2011-03-21 11:17:22 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2011-03-21 11:17:22 -0400 |
commit | 8fda34e4c77cac079b711da59d5fe49b74605553 (patch) | |
tree | 89a78cbc7980cdf33f8d5412e0868fac43039398 | |
parent | 0245f15c9c7bd2d043f0f6e59fff0a692d7466b1 (diff) |
get rid of checked exceptions
58 files changed, 2066 insertions, 1926 deletions
diff --git a/src/jvm/clojure/lang/AFn.java b/src/jvm/clojure/lang/AFn.java index 11a17305..f2d530a3 100644 --- a/src/jvm/clojure/lang/AFn.java +++ b/src/jvm/clojure/lang/AFn.java @@ -14,7 +14,7 @@ package clojure.lang; public abstract class AFn implements IFn { -public Object call() throws Exception{ +public Object call() { return invoke(); } @@ -25,116 +25,116 @@ public void run(){ } catch(Exception e) { - throw new RuntimeException(e); + throw Util.runtimeException(e); } } -public Object invoke() throws Exception{ +public Object invoke() { return throwArity(0); } -public Object invoke(Object arg1) throws Exception{ +public Object invoke(Object arg1) { return throwArity(1); } -public Object invoke(Object arg1, Object arg2) throws Exception{ +public Object invoke(Object arg1, Object arg2) { return throwArity(2); } -public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception{ +public Object invoke(Object arg1, Object arg2, Object arg3) { return throwArity(3); } -public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) throws Exception{ +public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) { return throwArity(4); } -public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) throws Exception{ +public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { return throwArity(5); } -public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) throws Exception{ +public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { return throwArity(6); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) - throws Exception{ + { return throwArity(7); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, - Object arg8) throws Exception{ + Object arg8) { return throwArity(8); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, - Object arg8, Object arg9) throws Exception{ + Object arg8, Object arg9) { return throwArity(9); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, - Object arg8, Object arg9, Object arg10) throws Exception{ + Object arg8, Object arg9, Object arg10) { return throwArity(10); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, - Object arg8, Object arg9, Object arg10, Object arg11) throws Exception{ + Object arg8, Object arg9, Object arg10, Object arg11) { return throwArity(11); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, - Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) throws Exception{ + Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) { return throwArity(12); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13) - throws Exception{ + { return throwArity(13); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14) - throws Exception{ + { return throwArity(14); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, - Object arg15) throws Exception{ + Object arg15) { return throwArity(15); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, - Object arg15, Object arg16) throws Exception{ + Object arg15, Object arg16) { return throwArity(16); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, - Object arg15, Object arg16, Object arg17) throws Exception{ + Object arg15, Object arg16, Object arg17) { return throwArity(17); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, - Object arg15, Object arg16, Object arg17, Object arg18) throws Exception{ + Object arg15, Object arg16, Object arg17, Object arg18) { return throwArity(18); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, - Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) throws Exception{ + Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) { return throwArity(19); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20) - throws Exception{ + { return throwArity(20); } @@ -143,15 +143,15 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20, Object... args) - throws Exception{ + { return throwArity(21); } -public Object applyTo(ISeq arglist) throws Exception{ +public Object applyTo(ISeq arglist) { return applyToHelper(this, Util.ret1(arglist,arglist = null)); } -static public Object applyToHelper(IFn ifn, ISeq arglist) throws Exception{ +static public Object applyToHelper(IFn ifn, ISeq arglist) { switch(RT.boundedLength(arglist, 20)) { case 0: diff --git a/src/jvm/clojure/lang/AFunction.java b/src/jvm/clojure/lang/AFunction.java index 908d2c38..d797102d 100644 --- a/src/jvm/clojure/lang/AFunction.java +++ b/src/jvm/clojure/lang/AFunction.java @@ -25,7 +25,7 @@ public IPersistentMap meta(){ public IObj withMeta(final IPersistentMap meta){ return new RestFn(){ - protected Object doInvoke(Object args) throws Exception{ + protected Object doInvoke(Object args) { return AFunction.this.applyTo((ISeq) args); } @@ -60,7 +60,7 @@ public int compare(Object o1, Object o2){ } catch(Exception e) { - throw new RuntimeException(e); + throw Util.runtimeException(e); } } } diff --git a/src/jvm/clojure/lang/AMapEntry.java b/src/jvm/clojure/lang/AMapEntry.java index 7b7d7507..f9e02467 100644 --- a/src/jvm/clojure/lang/AMapEntry.java +++ b/src/jvm/clojure/lang/AMapEntry.java @@ -78,7 +78,7 @@ public String toString(){ catch(Exception e) { //checked exceptions stink! - throw new RuntimeException(e); + throw Util.runtimeException(e); } return sw.toString(); } @@ -141,7 +141,7 @@ public Object peek(){ } -public ISeq rseq() throws Exception{ +public ISeq rseq() { return asVector().rseq(); } */ diff --git a/src/jvm/clojure/lang/APersistentMap.java b/src/jvm/clojure/lang/APersistentMap.java index d27dcb0f..4b911c2e 100644 --- a/src/jvm/clojure/lang/APersistentMap.java +++ b/src/jvm/clojure/lang/APersistentMap.java @@ -173,11 +173,11 @@ static public class ValSeq extends ASeq{ } -public Object invoke(Object arg1) throws Exception{ +public Object invoke(Object arg1) { return valAt(arg1); } -public Object invoke(Object arg1, Object notFound) throws Exception{ +public Object invoke(Object arg1, Object notFound) { return valAt(arg1, notFound); } diff --git a/src/jvm/clojure/lang/APersistentSet.java b/src/jvm/clojure/lang/APersistentSet.java index 80415151..5bae4484 100644 --- a/src/jvm/clojure/lang/APersistentSet.java +++ b/src/jvm/clojure/lang/APersistentSet.java @@ -45,7 +45,7 @@ public ISeq seq(){ return RT.keys(impl); } -public Object invoke(Object arg1) throws Exception{ +public Object invoke(Object arg1) { return get(arg1); } diff --git a/src/jvm/clojure/lang/APersistentVector.java b/src/jvm/clojure/lang/APersistentVector.java index 442c2ac6..16ed10f7 100644 --- a/src/jvm/clojure/lang/APersistentVector.java +++ b/src/jvm/clojure/lang/APersistentVector.java @@ -244,7 +244,7 @@ public boolean addAll(int i, Collection c){ } -public Object invoke(Object arg1) throws Exception{ +public Object invoke(Object arg1) { if(Util.isInteger(arg1)) return nth(((Number) arg1).intValue()); throw new IllegalArgumentException("Key must be integer"); @@ -445,14 +445,14 @@ public int compareTo(Object o){ return new APersistentVector.Seq(meta, v, i); } - public Object reduce(IFn f) throws Exception{ + public Object reduce(IFn f) { Object ret = v.nth(i); for(int x = i + 1; x < v.count(); x++) ret = f.invoke(ret, v.nth(x)); return ret; } - public Object reduce(IFn f, Object start) throws Exception{ + public Object reduce(IFn f, Object start) { Object ret = f.invoke(start, v.nth(i)); for(int x = i + 1; x < v.count(); x++) ret = f.invoke(ret, v.nth(x)); diff --git a/src/jvm/clojure/lang/ARef.java b/src/jvm/clojure/lang/ARef.java index 99c8c692..e9235c02 100644 --- a/src/jvm/clojure/lang/ARef.java +++ b/src/jvm/clojure/lang/ARef.java @@ -53,7 +53,7 @@ public void setValidator(IFn vf){ } catch(Exception e) { - throw new RuntimeException(e); + throw Util.runtimeException(e); } validator = vf; } @@ -78,7 +78,7 @@ synchronized public IRef removeWatch(Object key){ } catch(Exception e) { - throw new RuntimeException(e); + throw Util.runtimeException(e); } return this; @@ -99,7 +99,7 @@ public void notifyWatches(Object oldval, Object newval){ } catch(Exception e1) { - throw new RuntimeException(e1); + throw Util.runtimeException(e1); } } } diff --git a/src/jvm/clojure/lang/AReference.java b/src/jvm/clojure/lang/AReference.java index 246ba96b..fba59674 100644 --- a/src/jvm/clojure/lang/AReference.java +++ b/src/jvm/clojure/lang/AReference.java @@ -27,7 +27,7 @@ public class AReference implements IReference { return _meta; } - synchronized public IPersistentMap alterMeta(IFn alter, ISeq args) throws Exception { + synchronized public IPersistentMap alterMeta(IFn alter, ISeq args) { _meta = (IPersistentMap) alter.applyTo(new Cons(_meta, args)); return _meta; } diff --git a/src/jvm/clojure/lang/ASeq.java b/src/jvm/clojure/lang/ASeq.java index 286f767a..4e8522ac 100644 --- a/src/jvm/clojure/lang/ASeq.java +++ b/src/jvm/clojure/lang/ASeq.java @@ -1,259 +1,259 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
- * which can be found in the file epl-v10.html at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-package clojure.lang;
-
-import java.io.Serializable;
-import java.util.*;
-
+/** + * Copyright (c) Rich Hickey. All rights reserved. + * The use and distribution terms for this software are covered by the + * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) + * which can be found in the file epl-v10.html at the root of this distribution. + * By using this software in any fashion, you are agreeing to be bound by + * the terms of this license. + * You must not remove this notice, or any other, from this software. + **/ + +package clojure.lang; + +import java.io.Serializable; +import java.util.*; + public abstract class ASeq extends Obj implements ISeq, Sequential, List, Serializable { -transient int _hash = -1;
-
-public String toString(){
- return RT.printString(this);
-}
-
-public IPersistentCollection empty(){
- return PersistentList.EMPTY;
-}
-
-protected ASeq(IPersistentMap meta){
- super(meta);
-}
-
-
-protected ASeq(){
-}
-
-public boolean equiv(Object obj){
-
- if(!(obj instanceof Sequential || obj instanceof List))
- return false;
- ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
- {
- if(ms == null || !Util.equiv(s.first(), ms.first()))
- return false;
- }
- return ms == null;
-
-}
-
-public boolean equals(Object obj){
- if(this == obj) return true;
- if(!(obj instanceof Sequential || obj instanceof List))
- return false;
- ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
- {
- if(ms == null || !Util.equals(s.first(), ms.first()))
- return false;
- }
- return ms == null;
-
-}
-
-public int hashCode(){
- if(_hash == -1)
- {
- int hash = 1;
- for(ISeq s = seq(); s != null; s = s.next())
- {
- hash = 31 * hash + (s.first() == null ? 0 : s.first().hashCode());
- }
- this._hash = hash;
- }
- return _hash;
-}
-
-
-//public Object reduce(IFn f) throws Exception{
-// Object ret = first();
-// for(ISeq s = rest(); s != null; s = s.rest())
-// ret = f.invoke(ret, s.first());
-// return ret;
-//}
-//
-//public Object reduce(IFn f, Object start) throws Exception{
-// Object ret = f.invoke(start, first());
-// for(ISeq s = rest(); s != null; s = s.rest())
-// ret = f.invoke(ret, s.first());
-// return ret;
-//}
-
-//public Object peek(){
-// return first();
-//}
-//
-//public IPersistentList pop(){
-// return rest();
-//}
-
-public int count(){
- int i = 1;
- for(ISeq s = next(); s != null; s = s.next(), i++)
- if(s instanceof Counted)
- return i + s.count();
- return i;
-}
-
-final public ISeq seq(){
- return this;
-}
-
-public ISeq cons(Object o){
- return new Cons(o, this);
-}
-
-public ISeq more(){
- ISeq s = next();
- if(s == null)
- return PersistentList.EMPTY;
- return s;
-}
-
-//final public ISeq rest(){
-// Seqable m = more();
-// if(m == null)
-// return null;
-// return m.seq();
-//}
-
-// java.util.Collection implementation
-
-public Object[] toArray(){
- return RT.seqToArray(seq());
-}
-
-public boolean add(Object o){
- throw new UnsupportedOperationException();
-}
-
-public boolean remove(Object o){
- throw new UnsupportedOperationException();
-}
-
-public boolean addAll(Collection c){
- throw new UnsupportedOperationException();
-}
-
-public void clear(){
- throw new UnsupportedOperationException();
-}
-
-public boolean retainAll(Collection c){
- throw new UnsupportedOperationException();
-}
-
-public boolean removeAll(Collection c){
- throw new UnsupportedOperationException();
-}
-
-public boolean containsAll(Collection c){
- for(Object o : c)
- {
- if(!contains(o))
- return false;
- }
- return true;
-}
-
-public Object[] toArray(Object[] a){
- if(a.length >= count())
- {
- ISeq s = seq();
- for(int i = 0; s != null; ++i, s = s.next())
- {
- a[i] = s.first();
- }
- if(a.length > count())
- a[count()] = null;
- return a;
- }
- else
- return toArray();
-}
-
-public int size(){
- return count();
-}
-
-public boolean isEmpty(){
- return seq() == null;
-}
-
-public boolean contains(Object o){
- for(ISeq s = seq(); s != null; s = s.next())
- {
- if(Util.equiv(s.first(), o))
- return true;
- }
- return false;
-}
-
-
-public Iterator iterator(){
- return new SeqIterator(this);
-}
-
-
-
-//////////// List stuff /////////////////
-private List reify(){
- return Collections.unmodifiableList(new ArrayList(this));
-}
-
-public List subList(int fromIndex, int toIndex){
- return reify().subList(fromIndex, toIndex);
-}
-
-public Object set(int index, Object element){
- throw new UnsupportedOperationException();
-}
-
-public Object remove(int index){
- throw new UnsupportedOperationException();
-}
-
-public int indexOf(Object o){
- ISeq s = seq();
- for(int i = 0; s != null; s = s.next(), i++)
- {
- if(Util.equiv(s.first(), o))
- return i;
- }
- return -1;
-}
-
-public int lastIndexOf(Object o){
- return reify().lastIndexOf(o);
-}
-
-public ListIterator listIterator(){
- return reify().listIterator();
-}
-
-public ListIterator listIterator(int index){
- return reify().listIterator(index);
-}
-
-public Object get(int index){
- return RT.nth(this, index);
-}
-
-public void add(int index, Object element){
- throw new UnsupportedOperationException();
-}
-
-public boolean addAll(int index, Collection c){
- throw new UnsupportedOperationException();
-}
-
-}
+transient int _hash = -1; + +public String toString(){ + return RT.printString(this); +} + +public IPersistentCollection empty(){ + return PersistentList.EMPTY; +} + +protected ASeq(IPersistentMap meta){ + super(meta); +} + + +protected ASeq(){ +} + +public boolean equiv(Object obj){ + + if(!(obj instanceof Sequential || obj instanceof List)) + return false; + ISeq ms = RT.seq(obj); + for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next()) + { + if(ms == null || !Util.equiv(s.first(), ms.first())) + return false; + } + return ms == null; + +} + +public boolean equals(Object obj){ + if(this == obj) return true; + if(!(obj instanceof Sequential || obj instanceof List)) + return false; + ISeq ms = RT.seq(obj); + for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next()) + { + if(ms == null || !Util.equals(s.first(), ms.first())) + return false; + } + return ms == null; + +} + +public int hashCode(){ + if(_hash == -1) + { + int hash = 1; + for(ISeq s = seq(); s != null; s = s.next()) + { + |