Skip to content
Browse files

get rid of checked exceptions

1 parent 0245f15 commit 8fda34e4c77cac079b711da59d5fe49b74605553 @richhickey richhickey committed
Showing with 2,066 additions and 1,926 deletions.
  1. +26 −26 src/jvm/clojure/lang/AFn.java
  2. +2 −2 src/jvm/clojure/lang/AFunction.java
  3. +2 −2 src/jvm/clojure/lang/AMapEntry.java
  4. +2 −2 src/jvm/clojure/lang/APersistentMap.java
  5. +1 −1 src/jvm/clojure/lang/APersistentSet.java
  6. +3 −3 src/jvm/clojure/lang/APersistentVector.java
  7. +3 −3 src/jvm/clojure/lang/ARef.java
  8. +1 −1 src/jvm/clojure/lang/AReference.java
  9. +258 −258 src/jvm/clojure/lang/ASeq.java
  10. +2 −2 src/jvm/clojure/lang/ATransientMap.java
  11. +3 −3 src/jvm/clojure/lang/ATransientSet.java
  12. +6 −6 src/jvm/clojure/lang/Agent.java
  13. +1 −1 src/jvm/clojure/lang/ArrayChunk.java
  14. +16 −16 src/jvm/clojure/lang/ArraySeq.java
  15. +4 −4 src/jvm/clojure/lang/Atom.java
  16. +1 −1 src/jvm/clojure/lang/Compile.java
  17. +281 −244 src/jvm/clojure/lang/Compiler.java
  18. +2 −2 src/jvm/clojure/lang/Delay.java
  19. +13 −6 src/jvm/clojure/lang/FnLoaderThunk.java
  20. +1 −1 src/jvm/clojure/lang/IBlockingDeref.java
  21. +1 −1 src/jvm/clojure/lang/IChunk.java
  22. +3 −3 src/jvm/clojure/lang/IChunkedSeq.java
  23. +1 −1 src/jvm/clojure/lang/IDeref.java
  24. +23 −23 src/jvm/clojure/lang/IFn.java
  25. +23 −23 src/jvm/clojure/lang/IPersistentMap.java
  26. +1 −1 src/jvm/clojure/lang/IPersistentSet.java
  27. +2 −2 src/jvm/clojure/lang/IReduce.java
  28. +1 −1 src/jvm/clojure/lang/IReference.java
  29. +1 −1 src/jvm/clojure/lang/ITransientSet.java
  30. +25 −25 src/jvm/clojure/lang/Keyword.java
  31. +1 −1 src/jvm/clojure/lang/LazySeq.java
  32. +102 −84 src/jvm/clojure/lang/LispReader.java
  33. +7 −7 src/jvm/clojure/lang/LockingTransaction.java
  34. +33 −33 src/jvm/clojure/lang/MultiFn.java
  35. +2 −2 src/jvm/clojure/lang/Namespace.java
  36. +8 −8 src/jvm/clojure/lang/Numbers.java
  37. +2 −2 src/jvm/clojure/lang/PersistentArrayMap.java
  38. +2 −2 src/jvm/clojure/lang/PersistentHashMap.java
  39. +1 −1 src/jvm/clojure/lang/PersistentHashSet.java
  40. +3 −3 src/jvm/clojure/lang/PersistentList.java
  41. +6 −6 src/jvm/clojure/lang/PersistentStructMap.java
  42. +3 −3 src/jvm/clojure/lang/PersistentTreeMap.java
  43. +2 −2 src/jvm/clojure/lang/PersistentTreeSet.java
  44. +2 −2 src/jvm/clojure/lang/PersistentVector.java
  45. +51 −36 src/jvm/clojure/lang/RT.java
  46. +2 −2 src/jvm/clojure/lang/Range.java
  47. +29 −29 src/jvm/clojure/lang/Ref.java
  48. +76 −34 src/jvm/clojure/lang/Reflector.java
  49. +1 −1 src/jvm/clojure/lang/Repl.java
  50. +953 −953 src/jvm/clojure/lang/RestFn.java
  51. +1 −1 src/jvm/clojure/lang/Reversible.java
  52. +1 −1 src/jvm/clojure/lang/Script.java
  53. +2 −2 src/jvm/clojure/lang/Settable.java
  54. +2 −2 src/jvm/clojure/lang/Symbol.java
  55. +5 −5 src/jvm/clojure/lang/TransactionalHashMap.java
  56. +14 −0 src/jvm/clojure/lang/Util.java
  57. +43 −36 src/jvm/clojure/lang/Var.java
  58. +3 −3 src/jvm/clojure/main.java
View
52 src/jvm/clojure/lang/AFn.java
@@ -14,7 +14,7 @@
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:
View
4 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);
}
}
}
View
4 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();
}
*/
View
4 src/jvm/clojure/lang/APersistentMap.java
@@ -173,11 +173,11 @@ public ValSeq withMeta(IPersistentMap meta){
}
-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);
}
View
2 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);
}
View
6 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 count(){
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));
View
6 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);
}
}
}
View
2 src/jvm/clojure/lang/AReference.java
@@ -27,7 +27,7 @@ synchronized public IPersistentMap meta() {
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;
}
View
516 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())
+ {
+ hash = 31 * hash + (s.first() == null ? 0 : s.first().hashCode());
+ }
+ this._hash = hash;
+ }
+ return _hash;
+}
+
+
+//public Object reduce(IFn f) {
+// 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) {
+// 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();
+}
+
+}
View
4 src/jvm/clojure/lang/ATransientMap.java
@@ -47,11 +47,11 @@ else if(o instanceof IPersistentVector)
return ret;
}
- public final Object invoke(Object arg1) throws Exception{
+ public final Object invoke(Object arg1) {
return valAt(arg1);
}
- public final Object invoke(Object arg1, Object notFound) throws Exception{
+ public final Object invoke(Object arg1, Object notFound) {
return valAt(arg1, notFound);
}
View
6 src/jvm/clojure/lang/ATransientSet.java
@@ -33,7 +33,7 @@ public boolean contains(Object key) {
return this != impl.valAt(key, this);
}
- public ITransientSet disjoin(Object key) throws Exception {
+ public ITransientSet disjoin(Object key) {
ITransientMap m = impl.without(key);
if (m != impl) this.impl = m;
return this;
@@ -43,11 +43,11 @@ public Object get(Object key) {
return impl.valAt(key);
}
- public Object invoke(Object key, Object notFound) throws Exception {
+ public Object invoke(Object key, Object notFound) {
return impl.valAt(key, notFound);
}
- public Object invoke(Object key) throws Exception {
+ public Object invoke(Object key) {
return impl.valAt(key);
}
View
12 src/jvm/clojure/lang/Agent.java
@@ -166,23 +166,23 @@ public void run(){
}
}
-public Agent(Object state) throws Exception{
+public Agent(Object state) {
this(state,null);
}
-public Agent(Object state, IPersistentMap meta) throws Exception {
+public Agent(Object state, IPersistentMap meta) {
super(meta);
setState(state);
}
-boolean setState(Object newState) throws Exception{
+boolean setState(Object newState) {
validate(newState);
boolean ret = state != newState;
state = newState;
return ret;
}
-public Object deref() throws Exception{
+public Object deref() {
return state;
}
@@ -209,7 +209,7 @@ public IFn getErrorHandler(){
synchronized public Object restart(Object newState, boolean clearActions){
if(getError() == null)
{
- throw new RuntimeException("Agent does not need a restart");
+ throw Util.runtimeException("Agent does not need a restart");
}
validate(newState);
state = newState;
@@ -237,7 +237,7 @@ public Object dispatch(IFn fn, ISeq args, boolean solo) {
Throwable error = getError();
if(error != null)
{
- throw new RuntimeException("Agent is failed, needs restart", error);
+ throw Util.runtimeException("Agent is failed, needs restart", error);
}
Action action = new Action(this, fn, args, solo);
dispatchAction(action);
View
2 src/jvm/clojure/lang/ArrayChunk.java
@@ -54,7 +54,7 @@ public IChunk dropFirst(){
return new ArrayChunk(array, off + 1, end);
}
-public Object reduce(IFn f, Object start) throws Exception{
+public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, array[off]);
for(int x = off + 1; x < end; x++)
ret = f.invoke(ret, array[x]);
View
32 src/jvm/clojure/lang/ArraySeq.java
@@ -102,7 +102,7 @@ public ArraySeq withMeta(IPersistentMap meta){
return new ArraySeq(meta, array, i);
}
-public Object reduce(IFn f) throws Exception{
+public Object reduce(IFn f) {
if(oa != null)
{
Object ret = oa[i];
@@ -117,7 +117,7 @@ public Object reduce(IFn f) throws Exception{
return ret;
}
-public Object reduce(IFn f, Object start) throws Exception{
+public Object reduce(IFn f, Object start) {
if(oa != null)
{
Object ret = f.invoke(start, oa[i]);
@@ -198,14 +198,14 @@ public ArraySeq_int withMeta(IPersistentMap meta){
return new ArraySeq_int(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = array[i];
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
@@ -266,14 +266,14 @@ public ArraySeq_float withMeta(IPersistentMap meta){
return new ArraySeq_float(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = Numbers.num(array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, Numbers.num(array[x]));
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, Numbers.num(array[i]));
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, Numbers.num(array[x]));
@@ -331,14 +331,14 @@ public ArraySeq_double withMeta(IPersistentMap meta){
return new ArraySeq_double(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = array[i];
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
@@ -398,14 +398,14 @@ public ArraySeq_long withMeta(IPersistentMap meta){
return new ArraySeq_long(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = Numbers.num(array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, Numbers.num(array[x]));
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, Numbers.num(array[i]));
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, Numbers.num(array[x]));
@@ -465,14 +465,14 @@ public ArraySeq_byte withMeta(IPersistentMap meta){
return new ArraySeq_byte(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = array[i];
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
@@ -540,14 +540,14 @@ public ArraySeq_char withMeta(IPersistentMap meta){
return new ArraySeq_char(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = array[i];
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
@@ -615,14 +615,14 @@ public ArraySeq_boolean withMeta(IPersistentMap meta){
return new ArraySeq_boolean(meta, array, i);
}
- public Object reduce(IFn f) throws Exception{
+ public Object reduce(IFn f) {
Object ret = array[i];
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
return ret;
}
- public Object reduce(IFn f, Object start) throws Exception{
+ public Object reduce(IFn f, Object start) {
Object ret = f.invoke(start, array[i]);
for(int x = i + 1; x < array.length; x++)
ret = f.invoke(ret, array[x]);
View
8 src/jvm/clojure/lang/Atom.java
@@ -30,7 +30,7 @@ public Object deref(){
return state.get();
}
-public Object swap(IFn f) throws Exception{
+public Object swap(IFn f) {
for(; ;)
{
Object v = deref();
@@ -44,7 +44,7 @@ public Object swap(IFn f) throws Exception{
}
}
-public Object swap(IFn f, Object arg) throws Exception{
+public Object swap(IFn f, Object arg) {
for(; ;)
{
Object v = deref();
@@ -58,7 +58,7 @@ public Object swap(IFn f, Object arg) throws Exception{
}
}
-public Object swap(IFn f, Object arg1, Object arg2) throws Exception{
+public Object swap(IFn f, Object arg1, Object arg2) {
for(; ;)
{
Object v = deref();
@@ -72,7 +72,7 @@ public Object swap(IFn f, Object arg1, Object arg2) throws Exception{
}
}
-public Object swap(IFn f, Object x, Object y, ISeq args) throws Exception{
+public Object swap(IFn f, Object x, Object y, ISeq args) {
for(; ;)
{
Object v = deref();
View
2 src/jvm/clojure/lang/Compile.java
@@ -30,7 +30,7 @@
private static final Var warn_on_reflection = RT.var("clojure.core", "*warn-on-reflection*");
private static final Var unchecked_math = RT.var("clojure.core", "*unchecked-math*");
-public static void main(String[] args) throws Exception{
+public static void main(String[] args) throws IOException{
OutputStreamWriter out = (OutputStreamWriter) RT.OUT.deref();
PrintWriter err = RT.errPrintWriter();
View
525 src/jvm/clojure/lang/Compiler.java
281 additions, 244 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 src/jvm/clojure/lang/Delay.java
@@ -21,13 +21,13 @@ public Delay(IFn fn){
this.val = null;
}
-static public Object force(Object x) throws Exception{
+static public Object force(Object x) {
return (x instanceof Delay) ?
((Delay) x).deref()
: x;
}
-synchronized public Object deref() throws Exception{
+synchronized public Object deref() {
if(fn != null)
{
val = fn.invoke();
View
19 src/jvm/clojure/lang/FnLoaderThunk.java
@@ -26,30 +26,37 @@ public FnLoaderThunk(Var v, String fnClassName){
fn = null;
}
-public Object invoke(Object arg1) throws Exception{
+public Object invoke(Object arg1) {
load();
return fn.invoke(arg1);
}
-public Object invoke(Object arg1, Object arg2) throws Exception{
+public Object invoke(Object arg1, Object arg2) {
load();
return fn.invoke(arg1,arg2);
}
-public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception{
+public Object invoke(Object arg1, Object arg2, Object arg3) {
load();
return fn.invoke(arg1,arg2,arg3);
}
-protected Object doInvoke(Object args) throws Exception{
+protected Object doInvoke(Object args) {
load();
return fn.applyTo((ISeq) args);
}
-private void load() throws Exception{
+private void load() {
if(fn == null)
{
- fn = (IFn) Class.forName(fnClassName,true,loader).newInstance();
+ try
+ {
+ fn = (IFn) Class.forName(fnClassName,true,loader).newInstance();
+ }
+ catch(Exception e)
+ {
+ throw Util.runtimeException(e);
+ }
v.root = fn;
}
}
View
2 src/jvm/clojure/lang/IBlockingDeref.java
@@ -13,5 +13,5 @@
package clojure.lang;
public interface IBlockingDeref{
-Object deref(long ms, Object timeoutValue) throws Exception;
+Object deref(long ms, Object timeoutValue) ;
}
View
2 src/jvm/clojure/lang/IChunk.java
@@ -16,5 +16,5 @@
IChunk dropFirst();
-Object reduce(IFn f, Object start) throws Exception;
+Object reduce(IFn f, Object start) ;
}
View
6 src/jvm/clojure/lang/IChunkedSeq.java
@@ -14,10 +14,10 @@
public interface IChunkedSeq extends ISeq, Sequential {
-IChunk chunkedFirst() throws Exception;
+IChunk chunkedFirst() ;
-ISeq chunkedNext() throws Exception;
+ISeq chunkedNext() ;
-ISeq chunkedMore() throws Exception;
+ISeq chunkedMore() ;
}
View
2 src/jvm/clojure/lang/IDeref.java
@@ -13,5 +13,5 @@
package clojure.lang;
public interface IDeref{
-Object deref() throws Exception;
+Object deref() ;
}
View
46 src/jvm/clojure/lang/IFn.java
@@ -16,77 +16,77 @@
public interface IFn extends Callable, Runnable{
-public Object invoke() throws Exception;
+public Object invoke() ;
-public Object invoke(Object arg1) throws Exception;
+public Object invoke(Object arg1) ;
-public Object invoke(Object arg1, Object arg2) throws Exception;
+public Object invoke(Object arg1, Object arg2) ;
-public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception;
+public Object invoke(Object arg1, Object arg2, Object arg3) ;
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) throws Exception;
+public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) ;
-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) ;
-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) ;
public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- throws Exception;
+ ;
public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8) throws Exception;
+ Object arg8) ;
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) ;
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) ;
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) ;
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) ;
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;
+ Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13) ;
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;
+ ;
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) ;
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) ;
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) ;
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) ;
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) ;
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;
+ ;
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,
Object... args)
- throws Exception;
+ ;
-public Object applyTo(ISeq arglist) throws Exception;
+public Object applyTo(ISeq arglist) ;
static public interface L{long invokePrim();}
static public interface D{double invokePrim();}
View
46 src/jvm/clojure/lang/IPersistentMap.java
@@ -1,23 +1,23 @@
-/**
- * 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;
-
-
-public interface IPersistentMap extends Iterable, Associative, Counted{
-
-
-IPersistentMap assoc(Object key, Object val);
-
-IPersistentMap assocEx(Object key, Object val) throws Exception;
-
-IPersistentMap without(Object key) throws Exception;
-
-}
+/**
+ * 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;
+
+
+public interface IPersistentMap extends Iterable, Associative, Counted{
+
+
+IPersistentMap assoc(Object key, Object val);
+
+IPersistentMap assocEx(Object key, Object val) ;
+
+IPersistentMap without(Object key) ;
+
+}
View
2 src/jvm/clojure/lang/IPersistentSet.java
@@ -13,7 +13,7 @@
package clojure.lang;
public interface IPersistentSet extends IPersistentCollection, Counted{
- public IPersistentSet disjoin(Object key) throws Exception;
+ public IPersistentSet disjoin(Object key) ;
public boolean contains(Object key);
public Object get(Object key);
}
View
4 src/jvm/clojure/lang/IReduce.java
@@ -13,7 +13,7 @@
package clojure.lang;
public interface IReduce{
-Object reduce(IFn f) throws Exception;
+Object reduce(IFn f) ;
-Object reduce(IFn f, Object start) throws Exception;
+Object reduce(IFn f, Object start) ;
}
View
2 src/jvm/clojure/lang/IReference.java
@@ -13,6 +13,6 @@
package clojure.lang;
public interface IReference extends IMeta {
- IPersistentMap alterMeta(IFn alter, ISeq args) throws Exception;
+ IPersistentMap alterMeta(IFn alter, ISeq args) ;
IPersistentMap resetMeta(IPersistentMap m);
}
View
2 src/jvm/clojure/lang/ITransientSet.java
@@ -13,7 +13,7 @@
package clojure.lang;
public interface ITransientSet extends ITransientCollection, Counted{
- public ITransientSet disjoin(Object key) throws Exception;
+ public ITransientSet disjoin(Object key) ;
public boolean contains(Object key);
public Object get(Object key);
}
View
50 src/jvm/clojure/lang/Keyword.java
@@ -86,7 +86,7 @@ public Object throwArity(){
+ toString());
}
-public Object call() throws Exception{
+public Object call() {
return throwArity();
}
@@ -94,7 +94,7 @@ public void run(){
throw new UnsupportedOperationException();
}
-public Object invoke() throws Exception{
+public Object invoke() {
return throwArity();
}
@@ -120,112 +120,112 @@ private Object readResolve() throws ObjectStreamException{
*
* @param obj - must be IPersistentMap
* @return the value at the key or nil if not found
- * @throws Exception
+ * @
*/
-final public Object invoke(Object obj) throws Exception{
+final public Object invoke(Object obj) {
if(obj instanceof ILookup)
return ((ILookup)obj).valAt(this);
return RT.get(obj, this);
}
-final public Object invoke(Object obj, Object notFound) throws Exception{
+final public Object invoke(Object obj, Object notFound) {
if(obj instanceof ILookup)
return ((ILookup)obj).valAt(this,notFound);
return RT.get(obj, this, notFound);
}
-public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception{
+public Object invoke(Object arg1, Object arg2, Object arg3) {
return throwArity();
}
-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();
}
-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();
}
-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();
}
public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- throws Exception{
+ {
return throwArity();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
@@ -233,12 +233,12 @@ 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();
}
-public Object applyTo(ISeq arglist) throws Exception{
+public Object applyTo(ISeq arglist) {
return AFn.applyToHelper(this, arglist);
}
View
2 src/jvm/clojure/lang/LazySeq.java
@@ -48,7 +48,7 @@ final synchronized Object sval(){
}
catch(Exception e)
{
- throw new RuntimeException(e);
+ throw Util.runtimeException(e);
}
}
if(sv != null)
View
186 src/jvm/clojure/lang/LispReader.java
@@ -98,12 +98,19 @@ static boolean isWhitespace(int ch){
return Character.isWhitespace(ch) || ch == ',';
}
-static void unread(PushbackReader r, int ch) throws IOException{
+static void unread(PushbackReader r, int ch) {
if(ch != -1)
- r.unread(ch);
+ try
+ {
+ r.unread(ch);
+ }
+ catch(IOException e)
+ {
+ throw Util.runtimeException(e);
+ }
}
-public static class ReaderException extends Exception{
+public static class ReaderException extends RuntimeException{
final int line;
public ReaderException(int line, Throwable cause){
@@ -112,22 +119,33 @@ public ReaderException(int line, Throwable cause){
}
}
+static public int read1(Reader r){
+ try
+ {
+ return r.read();
+ }
+ catch(IOException e)
+ {
+ throw Util.runtimeException(e);
+ }
+}
+
static public Object read(PushbackReader r, boolean eofIsError, Object eofValue, boolean isRecursive)
- throws Exception{
+ {
try
{
for(; ;)
{
- int ch = r.read();
+ int ch = read1(r);
while(isWhitespace(ch))
- ch = r.read();
+ ch = read1(r);
if(ch == -1)
{
if(eofIsError)
- throw new Exception("EOF while reading");
+ throw Util.runtimeException("EOF while reading");
return eofValue;
}
@@ -153,7 +171,7 @@ static public Object read(PushbackReader r, boolean eofIsError, Object eofValue,
if(ch == '+' || ch == '-')
{
- int ch2 = r.read();
+ int ch2 = read1(r);
if(Character.isDigit(ch2))
{
unread(r, ch2);
@@ -174,20 +192,20 @@ static public Object read(PushbackReader r, boolean eofIsError, Object eofValue,
catch(Exception e)
{
if(isRecursive || !(r instanceof LineNumberingPushbackReader))
- throw e;
+ throw Util.runtimeException(e);
LineNumberingPushbackReader rdr = (LineNumberingPushbackReader) r;
- //throw new Exception(String.format("ReaderError:(%d,1) %s", rdr.getLineNumber(), e.getMessage()), e);
+ //throw Util.runtimeException(String.format("ReaderError:(%d,1) %s", rdr.getLineNumber(), e.getMessage()), e);
throw new ReaderException(rdr.getLineNumber(), e);
}
}
-static private String readToken(PushbackReader r, char initch) throws Exception{
+static private String readToken(PushbackReader r, char initch) {
StringBuilder sb = new StringBuilder();
sb.append(initch);
for(; ;)
{
- int ch = r.read();
+ int ch = read1(r);
if(ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch))
{
unread(r, ch);
@@ -197,13 +215,13 @@ static private String readToken(PushbackReader r, char initch) throws Exception{
}
}
-static private Object readNumber(PushbackReader r, char initch) throws Exception{
+static private Object readNumber(PushbackReader r, char initch) {
StringBuilder sb = new StringBuilder();
sb.append(initch);
for(; ;)
{
- int ch = r.read();
+ int ch = read1(r);
if(ch == -1 || isWhitespace(ch) || isMacro(ch))
{
unread(r, ch);
@@ -219,7 +237,7 @@ static private Object readNumber(PushbackReader r, char initch) throws Exception
return n;
}
-static private int readUnicodeChar(String token, int offset, int length, int base) throws Exception{
+static private int readUnicodeChar(String token, int offset, int length, int base) {
if(token.length() != offset + length)
throw new IllegalArgumentException("Invalid unicode character: \\" + token);
int uc = 0;
@@ -233,14 +251,14 @@ static private int readUnicodeChar(String token, int offset, int length, int bas
return (char) uc;
}
-static private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) throws Exception{
+static private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {
int uc = Character.digit(initch, base);
if(uc == -1)
throw new IllegalArgumentException("Invalid digit: " + initch);
int i = 1;
for(; i < length; ++i)
{
- int ch = r.read();
+ int ch = read1(r);
if(ch == -1 || isWhitespace(ch) || isMacro(ch))
{
unread(r, ch);
@@ -256,7 +274,7 @@ static private int readUnicodeChar(PushbackReader r, int initch, int base, int l
return uc;
}
-static private Object interpretToken(String s) throws Exception{
+static private Object interpretToken(String s) {
if(s.equals("nil"))
{
return null;
@@ -283,7 +301,7 @@ else if(s.equals("clojure.core//"))
if(ret != null)
return ret;
- throw new Exception("Invalid token: " + s);
+ throw Util.runtimeException("Invalid token: " + s);
}
@@ -387,19 +405,19 @@ static private boolean isTerminatingMacro(int ch){
public static class RegexReader extends AFn{
static StringReader stringrdr = new StringReader();
- public Object invoke(Object reader, Object doublequote) throws Exception{
+ public Object invoke(Object reader, Object doublequote) {
StringBuilder sb = new StringBuilder();
Reader r = (Reader) reader;
- for(int ch = r.read(); ch != '"'; ch = r.read())
+ for(int ch = read1(r); ch != '"'; ch = read1(r))
{
if(ch == -1)
- throw new Exception("EOF while reading regex");
+ throw Util.runtimeException("EOF while reading regex");
sb.append( (char) ch );
if(ch == '\\') //escape
{
- ch = r.read();
+ ch = read1(r);
if(ch == -1)
- throw new Exception("EOF while reading regex");
+ throw Util.runtimeException("EOF while reading regex");
sb.append( (char) ch ) ;
}
}
@@ -408,19 +426,19 @@ public Object invoke(Object reader, Object doublequote) throws Exception{
}
public static class StringReader extends AFn{
- public Object invoke(Object reader, Object doublequote) throws Exception{
+ public Object invoke(Object reader, Object doublequote) {
StringBuilder sb = new StringBuilder();
Reader r = (Reader) reader;
- for(int ch = r.read(); ch != '"'; ch = r.read())
+ for(int ch = read1(r); ch != '"'; ch = read1(r))
{
if(ch == -1)
- throw new Exception("EOF while reading string");
+ throw Util.runtimeException("EOF while reading string");
if(ch == '\\') //escape
{
- ch = r.read();
+ ch = read1(r);
if(ch == -1)
- throw new Exception("EOF while reading string");
+ throw Util.runtimeException("EOF while reading string");
switch(ch)
{
case 't':
@@ -444,9 +462,9 @@ public Object invoke(Object reader, Object doublequote) throws Exception{
break;
case 'u':
{
- ch = r.read();
+ ch = read1(r);
if (Character.digit(ch, 16) == -1)
- throw new Exception("Invalid unicode escape: \\u" + (char) ch);