Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

get rid of checked exceptions

  • Loading branch information...
commit 8fda34e4c77cac079b711da59d5fe49b74605553 1 parent 0245f15
@richhickey richhickey authored
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
@@ -28,6 +28,7 @@
//*/
import java.io.*;
+import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
@@ -152,7 +153,8 @@
final static Type IOBJ_TYPE = Type.getType(IObj.class);
private static final Type[][] ARG_TYPES;
-private static final Type[] EXCEPTION_TYPES = {Type.getType(Exception.class)};
+//private static final Type[] EXCEPTION_TYPES = {Type.getType(Exception.class)};
+private static final Type[] EXCEPTION_TYPES = {};
static
{
@@ -273,13 +275,13 @@
}
interface Expr{
- Object eval() throws Exception;
+ Object eval() ;
void emit(C context, ObjExpr objx, GeneratorAdapter gen);
- boolean hasJavaClass() throws Exception;
+ boolean hasJavaClass() ;
- Class getJavaClass() throws Exception;
+ Class getJavaClass() ;
}
public static abstract class UntypedExpr implements Expr{
@@ -294,7 +296,7 @@ public boolean hasJavaClass(){
}
interface IParser{
- Expr parse(C context, Object form) throws Exception;
+ Expr parse(C context, Object form) ;
}
static boolean isSpecial(Object sym){
@@ -362,7 +364,7 @@ private boolean includesExplicitMetadata(MapExpr expr) {
return false;
}
- public Object eval() throws Exception{
+ public Object eval() {
try
{
if(initProvided)
@@ -431,7 +433,7 @@ public Class getJavaClass(){
}
static class Parser implements IParser{
- public Expr parse(C context, Object form) throws Exception{
+ public Expr parse(C context, Object form) {
//(def x) or (def x initexpr) or (def x "docstring" initexpr)
String docstring = null;
if(RT.count(form) == 4 && (RT.third(form) instanceof String)) {
@@ -439,23 +441,23 @@ public Expr parse(C context, Object form) throws Exception{
form = RT.list(RT.first(form), RT.second(form), RT.fourth(form));
}
if(RT.count(form) > 3)
- throw new Exception("Too many arguments to def");
+ throw Util.runtimeException("Too many arguments to def");
else if(RT.count(form) < 2)
- throw new Exception("Too few arguments to def");
+ throw Util.runtimeException("Too few arguments to def");
else if(!(RT.second(form) instanceof Symbol))
- throw new Exception("First argument to def must be a Symbol");
+ throw Util.runtimeException("First argument to def must be a Symbol");
Symbol sym = (Symbol) RT.second(form);
Var v = lookupVar(sym, true);
if(v == null)
- throw new Exception("Can't refer to qualified var that doesn't exist");
+ throw Util.runtimeException("Can't refer to qualified var that doesn't exist");
if(!v.ns.equals(currentNS()))
{
if(sym.ns == null)
v = currentNS().intern(sym);
-// throw new Exception("Name conflict, can't def " + sym + " because namespace: " + currentNS().name +
+// throw Util.runtimeException("Name conflict, can't def " + sym + " because namespace: " + currentNS().name +
// " refers to:" + v);
else
- throw new Exception("Can't create defs outside of current ns");
+ throw Util.runtimeException("Can't create defs outside of current ns");
}
IPersistentMap mm = sym.meta();
boolean isDynamic = RT.booleanCast(RT.get(mm,dynamicKey));
@@ -504,7 +506,7 @@ public AssignExpr(AssignableExpr target, Expr val){
this.val = val;
}
- public Object eval() throws Exception{
+ public Object eval() {
return target.evalAssign(val);
}
@@ -512,16 +514,16 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
target.emitAssign(context, objx, gen, val);
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return val.hasJavaClass();
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return val.getJavaClass();
}
static class Parser implements IParser{
- public Expr parse(C context, Object frm) throws Exception{
+ public Expr parse(C context, Object frm) {
ISeq form = (ISeq) frm;
if(RT.length(form) != 3)
throw new IllegalArgumentException("Malformed assignment, expecting (set! target val)");
@@ -544,7 +546,7 @@ public VarExpr(Var var, Symbol tag){
this.tag = tag != null ? tag : var.getTag();
}
- public Object eval() throws Exception{
+ public Object eval() {
return var.deref();
}
@@ -560,11 +562,11 @@ public boolean hasJavaClass(){
return tag != null;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return HostExpr.tagToClass(tag);
}
- public Object evalAssign(Expr val) throws Exception{
+ public Object evalAssign(Expr val) {
return var.set(val.eval());
}
@@ -585,7 +587,7 @@ public TheVarExpr(Var var){
this.var = var;
}
- public Object eval() throws Exception{
+ public Object eval() {
return var;
}
@@ -599,17 +601,17 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws ClassNotFoundException{
+ public Class getJavaClass() {
return Var.class;
}
static class Parser implements IParser{
- public Expr parse(C context, Object form) throws Exception{
+ public Expr parse(C context, Object form) {
Symbol sym = (Symbol) RT.second(form);
Var v = lookupVar(sym, false);
if(v != null)
return new TheVarExpr(v);
- throw new Exception("Unable to resolve var: " + sym + " in this context");
+ throw Util.runtimeException("Unable to resolve var: " + sym + " in this context");
}
}
}
@@ -640,7 +642,7 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws ClassNotFoundException{
+ public Class getJavaClass() {
return Keyword.class;
}
}
@@ -655,7 +657,7 @@ public ImportExpr(String c){
this.c = c;
}
- public Object eval() throws Exception{
+ public Object eval() {
Namespace ns = (Namespace) RT.CURRENT_NS.deref();
ns.importClass(RT.classForName(c));
return null;
@@ -676,12 +678,12 @@ public boolean hasJavaClass(){
return false;
}
- public Class getJavaClass() throws ClassNotFoundException{
+ public Class getJavaClass() {
throw new IllegalArgumentException("ImportExpr has no Java class");
}
static class Parser implements IParser{
- public Expr parse(C context, Object form) throws Exception{
+ public Expr parse(C context, Object form) {
return new ImportExpr((String) RT.second(form));
}
}
@@ -696,7 +698,7 @@ public Object eval(){
}
static interface AssignableExpr{
- Object evalAssign(Expr val) throws Exception;
+ Object evalAssign(Expr val) ;
void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen, Expr val);
}
@@ -854,7 +856,7 @@ else if(paramType == short.class)
}
static class Parser implements IParser{
- public Expr parse(C context, Object frm) throws Exception{
+ public Expr parse(C context, Object frm) {
ISeq form = (ISeq) frm;
//(. x fieldname-sym) or
//(. x 0-ary-method)
@@ -911,7 +913,7 @@ else if(instance != null && instance.hasJavaClass() && instance.getJavaClass() !
}
}
- private static Class maybeClass(Object form, boolean stringOk) throws Exception{
+ private static Class maybeClass(Object form, boolean stringOk) {
if(form instanceof Class)
return (Class) form;
Class c = null;
@@ -968,7 +970,7 @@ else if(stringOk && form instanceof String)
return className;
}
*/
- static Class tagToClass(Object tag) throws Exception{
+ static Class tagToClass(Object tag) {
Class c = maybeClass(tag, true);
if(tag instanceof Symbol)
{
@@ -1015,7 +1017,7 @@ else if(sym.name.equals("booleans"))
final static Method setInstanceFieldMethod = Method.getMethod("Object setInstanceField(Object,String,Object)");
- public InstanceFieldExpr(int line, Expr target, String fieldName, Symbol tag) throws Exception{
+ public InstanceFieldExpr(int line, Expr target, String fieldName, Symbol tag) {
this.target = target;
this.targetClass = target.hasJavaClass() ? target.getJavaClass() : null;
this.field = targetClass != null ? Reflector.getField(targetClass, fieldName, false) : null;
@@ -1030,7 +1032,7 @@ public InstanceFieldExpr(int line, Expr target, String fieldName, Symbol tag) th
}
}
- public Object eval() throws Exception{
+ public Object eval() {
return Reflector.invokeNoArgInstanceMember(target.eval(), fieldName);
}
@@ -1075,15 +1077,15 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return field != null || tag != null;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return tag != null ? HostExpr.tagToClass(tag) : field.getType();
}
- public Object evalAssign(Expr val) throws Exception{
+ public Object evalAssign(Expr val) {
return Reflector.setInstanceField(target.eval(), fieldName, val.eval());
}
@@ -1121,17 +1123,24 @@ public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
// final static Method setStaticFieldMethod = Method.getMethod("Object setStaticField(String,String,Object)");
final int line;
- public StaticFieldExpr(int line, Class c, String fieldName, Symbol tag) throws Exception{
+ public StaticFieldExpr(int line, Class c, String fieldName, Symbol tag) {
//this.className = className;
this.fieldName = fieldName;
this.line = line;
//c = Class.forName(className);
this.c = c;
- field = c.getField(fieldName);
+ try
+ {
+ field = c.getField(fieldName);
+ }
+ catch(NoSuchFieldException e)
+ {
+ throw Util.runtimeException(e);
+ }
this.tag = tag;
}
- public Object eval() throws Exception{
+ public Object eval() {
return Reflector.getStaticField(c, fieldName);
}
@@ -1163,13 +1172,13 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
//Class c = Class.forName(className);
//java.lang.reflect.Field field = c.getField(fieldName);
return tag != null ? HostExpr.tagToClass(tag) : field.getType();
}
- public Object evalAssign(Expr val) throws Exception{
+ public Object evalAssign(Expr val) {
return Reflector.setStaticField(c, fieldName, val.eval());
}
@@ -1199,7 +1208,7 @@ static Class maybePrimitiveType(Expr e){
}
catch(Exception ex)
{
- throw new RuntimeException(ex);
+ throw Util.runtimeException(ex);
}
return null;
}
@@ -1285,7 +1294,7 @@ else if(primc == double.class && parameterTypes[i] == float.class)
public InstanceMethodExpr(String source, int line, Symbol tag, Expr target, String methodName, IPersistentVector args)
- throws Exception{
+ {
this.source = source;
this.line = line;
this.args = args;
@@ -1334,7 +1343,7 @@ public InstanceMethodExpr(String source, int line, Symbol tag, Expr target, Stri
}
}
- public Object eval() throws Exception{
+ public Object eval() {
try
{
Object targetval = target.eval();
@@ -1428,7 +1437,7 @@ public boolean hasJavaClass(){
return method != null || tag != null;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return tag != null ? HostExpr.tagToClass(tag) : method.getReturnType();
}
}
@@ -1449,7 +1458,7 @@ public Class getJavaClass() throws Exception{
public StaticMethodExpr(String source, int line, Symbol tag, Class c, String methodName, IPersistentVector args)
- throws Exception{
+ {
this.c = c;
this.methodName = methodName;
this.args = args;
@@ -1483,7 +1492,7 @@ public StaticMethodExpr(String source, int line, Symbol tag, Class c, String met
}
}
- public Object eval() throws Exception{
+ public Object eval() {
try
{
Object[] argvals = new Object[args.count()];
@@ -1578,7 +1587,7 @@ public boolean hasJavaClass(){
return method != null || tag != null;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return tag != null ? HostExpr.tagToClass(tag) : method.getReturnType();
}
}
@@ -1594,7 +1603,7 @@ public boolean hasJavaClass(){
return false;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
throw new IllegalArgumentException(
"UnresolvedVarExpr has no Java class");
}
@@ -1602,7 +1611,7 @@ public Class getJavaClass() throws Exception{
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
- public Object eval() throws Exception{
+ public Object eval() {
throw new IllegalArgumentException(
"UnresolvedVarExpr cannot be evalled");
}
@@ -1630,7 +1639,7 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return true;
}
@@ -1705,7 +1714,7 @@ public boolean hasJavaClass(){
//return false;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return v.getClass();
//throw new IllegalArgumentException("Has no Java class");
}
@@ -1748,7 +1757,7 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return null;
}
}
@@ -1782,7 +1791,7 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return Boolean.class;
}
}
@@ -1810,7 +1819,7 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return String.class;
}
}
@@ -1823,7 +1832,7 @@ public MonitorEnterExpr(Expr target){
this.target = target;
}
- public Object eval() throws Exception{
+ public Object eval() {
throw new UnsupportedOperationException("Can't eval monitor-enter");
}
@@ -1834,7 +1843,7 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
static class Parser implements IParser{
- public Expr parse(C context, Object form) throws Exception{
+ public Expr parse(C context, Object form) {
return new MonitorEnterExpr(analyze(C.EXPRESSION, RT.second(form)));
}
}
@@ -1847,7 +1856,7 @@ public MonitorExitExpr(Expr target){
this.target = target;
}
- public Object eval() throws Exception{
+ public Object eval() {
throw new UnsupportedOperationException("Can't eval monitor-exit");
}
@@ -1858,7 +1867,7 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
static class Parser implements IParser{
- public Expr parse(C context, Object form) throws Exception{
+ public Expr parse(C context, Object form) {
return new MonitorExitExpr(analyze(C.EXPRESSION, RT.second(form)));
}
}
@@ -1896,7 +1905,7 @@ public TryExpr(Expr tryExpr, PersistentVector catchExprs, Expr finallyExpr, int
this.finallyLocal = finallyLocal;
}
- public Object eval() throws Exception{
+ public Object eval() {
throw new UnsupportedOperationException("Can't eval try");
}
@@ -1973,17 +1982,17 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return tryExpr.hasJavaClass();
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return tryExpr.getJavaClass();
}
static class Parser implements IParser{
- public Expr parse(C context, Object frm) throws Exception{
+ public Expr parse(C context, Object frm) {
ISeq form = (ISeq) frm;
// if(context == C.EVAL || context == C.EXPRESSION)
if(context != C.RETURN)
@@ -2008,7 +2017,7 @@ public Expr parse(C context, Object frm) throws Exception{
if(!Util.equals(op, CATCH) && !Util.equals(op, FINALLY))
{
if(caught)
- throw new Exception("Only catch or finally clause can follow catch in try expression");
+ throw Util.runtimeException("Only catch or finally clause can follow catch in try expression");
body = body.cons(f);
}
else
@@ -2030,7 +2039,7 @@ public Expr parse(C context, Object frm) throws Exception{
"Bad binding form, expected symbol, got: " + RT.third(f));
Symbol sym = (Symbol) RT.third(f);
if(sym.getNamespace() != null)
- throw new Exception("Can't bind qualified name:" + sym);
+ throw Util.runtimeException("Can't bind qualified name:" + sym);
IPersistentMap dynamicBindings = RT.map(LOCAL_ENV, LOCAL_ENV.deref(),
NEXT_LOCAL_NUM, NEXT_LOCAL_NUM.deref(),
@@ -2054,7 +2063,7 @@ public Expr parse(C context, Object frm) throws Exception{
else //finally
{
if(fs.next() != null)
- throw new Exception("finally clause must be last in try expression");
+ throw Util.runtimeException("finally clause must be last in try expression");
try
{
Var.pushThreadBindings(RT.map(IN_CATCH_FINALLY, RT.T));
@@ -2095,7 +2104,7 @@ public Expr parse(C context, Object frm) throws Exception{
// this.finallyExpr = finallyExpr;
// }
//
-// public Object eval() throws Exception{
+// public Object eval() {
// throw new UnsupportedOperationException("Can't eval try");
// }
//
@@ -2117,16 +2126,16 @@ public Expr parse(C context, Object frm) throws Exception{
// gen.mark(end);
// }
//
-// public boolean hasJavaClass() throws Exception{
+// public boolean hasJavaClass() {
// return tryExpr.hasJavaClass();
// }
//
-// public Class getJavaClass() throws Exception{
+// public Class getJavaClass() {
// return tryExpr.getJavaClass();
// }
//
// static class Parser implements IParser{
-// public Expr parse(C context, Object frm) throws Exception{
+// public Expr parse(C context, Object frm) {
// ISeq form = (ISeq) frm;
// //(try-finally try-expr finally-expr)
// if(form.count() != 3)
@@ -2150,8 +2159,8 @@ public ThrowExpr(Expr excExpr){
}
- public Object eval() throws Exception{
- throw new Exception("Can't eval throw");
+ public Object eval() {
+ throw Util.runtimeException("Can't eval throw");
}
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
@@ -2161,7 +2170,7 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
static class Parser implements IParser{
- public Expr parse(C context, Object form) throws Exception{
+ public Expr parse(C context, Object form) {
if(context == C.EVAL)
return analyze(context, RT.list(RT.list(FN, PersistentVector.EMPTY, form)));
return new ThrowExpr(analyze(C.EXPRESSION, RT.second(form)));
@@ -2191,7 +2200,7 @@ static public boolean subsumes(Class[] c1, Class[] c2){
static int getMatchingParams(String methodName, ArrayList<Class[]> paramlists, IPersistentVector argexprs,
List<Class> rets)
- throws Exception{
+ {
//presumes matching lengths
int matchIdx = -1;
boolean tied = false;
@@ -2254,7 +2263,7 @@ else if(!(subsumes(paramlists.get(matchIdx), paramlists.get(i))))
final static Method forNameMethod = Method.getMethod("Class forName(String)");
- public NewExpr(Class c, IPersistentVector args, int line) throws Exception{
+ public NewExpr(Class c, IPersistentVector args, int line) {
this.args = args;
this.c = c;
Constructor[] allctors = c.getConstructors();
@@ -2289,13 +2298,20 @@ public NewExpr(Class c, IPersistentVector args, int line) throws Exception{
}
}
- public Object eval() throws Exception{
+ public Object eval() {
Object[] argvals = new Object[args.count()];
for(int i = 0; i < args.count(); i++)
argvals[i] = ((Expr) args.nth(i)).eval();
if(this.ctor != null)
{
- return ctor.newInstance(Reflector.boxArgs(ctor.getParameterTypes(), argvals));
+ try
+ {
+ return ctor.newInstance(Reflector.boxArgs(ctor.getParameterTypes(), argvals));
+ }
+ catch(Exception e)
+ {
+ throw Util.runtimeException(e);
+ }
}
return Reflector.invokeConstructor(c, argvals);
}
@@ -2334,17 +2350,17 @@ public boolean hasJavaClass(){
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return c;
}
static class Parser implements IParser{
- public Expr parse(C context, Object frm) throws Exception{
+ public Expr parse(C context, Object frm) {
int line = (Integer) LINE.deref();
ISeq form = (ISeq) frm;
//(new Classname args...)
if(form.count() < 2)
- throw new Exception("wrong number of arguments, expecting: (new Classname args...)");
+ throw Util.runtimeException("wrong number of arguments, expecting: (new Classname args...)");
Class c = HostExpr.maybeClass(RT.second(form), false);
if(c == null)
throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form));
@@ -2369,7 +2385,7 @@ public MetaExpr(Expr expr, Expr meta){
this.meta = meta;
}
- public Object eval() throws Exception{
+ public Object eval() {
return ((IObj) expr.eval()).withMeta((IPersistentMap) meta.eval());
}
@@ -2385,11 +2401,11 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
}
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return expr.hasJavaClass();
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return expr.getJavaClass();
}
}
@@ -2408,7 +2424,7 @@ public IfExpr(int line, Expr testExpr, Expr thenExpr, Expr elseExpr){
this.line = line;
}
- public Object eval() throws Exception{
+ public Object eval() {
Object t = testExpr.eval();
if(t != null && t != Boolean.FALSE)
return thenExpr.eval();
@@ -2448,7 +2464,7 @@ public void doEmit(C context, ObjExpr objx, GeneratorAdapter gen, boolean emitUn
}
catch(Exception e)
{
- throw new RuntimeException(e);
+ throw Util.runtimeException(e);
}
if(emitUnboxed)
((MaybePrimitiveExpr)thenExpr).emitUnboxed(context, objx, gen);
@@ -2465,7 +2481,7 @@ public void doEmit(C context, ObjExpr objx, GeneratorAdapter gen, boolean emitUn
gen.mark(endLabel);
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return thenExpr.hasJavaClass()
&& elseExpr.hasJavaClass()
&&
@@ -2489,7 +2505,7 @@ public boolean canEmitPrimitive(){
}
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
Class thenClass = thenExpr.getJavaClass();
if(thenClass != null)
return thenClass;
@@ -2497,13 +2513,13 @@ public Class getJavaClass() throws Exception{
}
static class Parser implements IParser{
- public Expr parse(C context, Object frm) throws Exception{
+ public Expr parse(C context, Object frm) {
ISeq form = (ISeq) frm;
//(if test then) or (if test then else)
if(form.count() > 4)
- throw new Exception("Too many arguments to if");
+ throw Util.runtimeException("Too many arguments to if");
else if(form.count() < 3)
- throw new Exception("Too few arguments to if");
+ throw Util.runtimeException("Too few arguments to if");
PathNode branch = new PathNode(PATHTYPE.BRANCH, (PathNode) CLEAR_PATH.get());
Expr testexpr = analyze(context == C.EVAL ? context : C.EXPRESSION, RT.second(form));
Expr thenexpr, elseexpr;
@@ -2584,7 +2600,7 @@ public EmptyExpr(Object coll){
this.coll = coll;
}
- public Object eval() throws Exception{
+ public Object eval() {
return coll;
}
@@ -2605,11 +2621,11 @@ else if(coll instanceof IPersistentSet)
}
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
if(coll instanceof IPersistentList)
return IPersistentList.class;
else if(coll instanceof IPersistentVector)
@@ -2632,7 +2648,7 @@ public ListExpr(IPersistentVector args){
this.args = args;
}
- public Object eval() throws Exception{
+ public Object eval() {
IPersistentVector ret = PersistentVector.EMPTY;
for(int i = 0; i < args.count(); i++)
ret = (IPersistentVector) ret.cons(((Expr) args.nth(i)).eval());
@@ -2646,11 +2662,11 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
gen.pop();
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return IPersistentList.class;
}
@@ -2665,7 +2681,7 @@ public MapExpr(IPersistentVector keyvals){
this.keyvals = keyvals;
}
- public Object eval() throws Exception{
+ public Object eval() {
Object[] ret = new Object[keyvals.count()];
for(int i = 0; i < keyvals.count(); i++)
ret[i] = ((Expr) keyvals.nth(i)).eval();
@@ -2679,16 +2695,16 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
gen.pop();
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return IPersistentMap.class;
}
- static public Expr parse(C context, IPersistentMap form) throws Exception{
+ static public Expr parse(C context, IPersistentMap form) {
IPersistentVector keyvals = PersistentVector.EMPTY;
boolean constant = true;
for(ISeq s = RT.seq(form); s != null; s = s.next())
@@ -2730,7 +2746,7 @@ public SetExpr(IPersistentVector keys){
this.keys = keys;
}
- public Object eval() throws Exception{
+ public Object eval() {
Object[] ret = new Object[keys.count()];
for(int i = 0; i < keys.count(); i++)
ret[i] = ((Expr) keys.nth(i)).eval();
@@ -2744,16 +2760,16 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
gen.pop();
}
- public boolean hasJavaClass() throws Exception{
+ public boolean hasJavaClass() {
return true;
}
- public Class getJavaClass() throws Exception{
+ public Class getJavaClass() {
return IPersistentSet.class;
}
- static public Expr parse(C context, IPersistentSet form) throws Exception{
+ static public Expr parse(C context, IPersistentSet form) {