Skip to content

Commit

Permalink
let undeclared exceptions continue unchecked
Browse files Browse the repository at this point in the history
The recent modifications regarding checked exceptions have
eliminated the need for several try/catch blocks. This
commit removes the blocks that no longer serve a purpose.

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
netguy204 authored and stuarthalloway committed Nov 22, 2013
1 parent 2224dba commit 047ca37
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 142 deletions.
9 changes: 1 addition & 8 deletions src/jvm/clojure/lang/AFn.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ public Object call() {
}

public void run(){
try
{
invoke();
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
invoke();
}


Expand Down
25 changes: 9 additions & 16 deletions src/jvm/clojure/lang/AFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,16 @@ public int getRequiredArity(){
}

public int compare(Object o1, Object o2){
try
{
Object o = invoke(o1, o2);
Object o = invoke(o1, o2);

if(o instanceof Boolean)
{
if(RT.booleanCast(o))
return -1;
return RT.booleanCast(invoke(o2,o1))? 1 : 0;
}
if(o instanceof Boolean)
{
if(RT.booleanCast(o))
return -1;
return RT.booleanCast(invoke(o2,o1))? 1 : 0;
}

Number n = (Number) o;
return n.intValue();
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
Number n = (Number) o;
return n.intValue();
}
}
30 changes: 4 additions & 26 deletions src/jvm/clojure/lang/ARef.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ void validate(Object val){
}

public void setValidator(IFn vf){
try
{
validate(vf, deref());
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
validate(vf, deref());
validator = vf;
}

Expand All @@ -72,15 +65,7 @@ synchronized public IRef addWatch(Object key, IFn callback){
}

synchronized public IRef removeWatch(Object key){
try
{
watches = watches.without(key);
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}

watches = watches.without(key);
return this;
}

Expand All @@ -92,15 +77,8 @@ public void notifyWatches(Object oldval, Object newval){
{
Map.Entry e = (Map.Entry) s.first();
IFn fn = (IFn) e.getValue();
try
{
if(fn != null)
fn.invoke(e.getKey(), this, oldval, newval);
}
catch(Exception e1)
{
throw Util.sneakyThrow(e1);
}
if(fn != null)
fn.invoke(e.getKey(), this, oldval, newval);
}
}
}
Expand Down
29 changes: 5 additions & 24 deletions src/jvm/clojure/lang/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1268,18 +1268,11 @@ public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
}

static Class maybePrimitiveType(Expr e){
try
{
if(e instanceof MaybePrimitiveExpr && e.hasJavaClass() && ((MaybePrimitiveExpr)e).canEmitPrimitive())
{
Class c = e.getJavaClass();
if(Util.isPrimitive(c))
return c;
}
}
catch(Exception ex)
{
throw Util.sneakyThrow(ex);
if(e instanceof MaybePrimitiveExpr && e.hasJavaClass() && ((MaybePrimitiveExpr)e).canEmitPrimitive())
{
Class c = e.getJavaClass();
if(Util.isPrimitive(c))
return c;
}
return null;
}
Expand Down Expand Up @@ -6793,25 +6786,13 @@ static PathNode commonPath(PathNode n1, PathNode n2){
}

static void addAnnotation(Object visitor, IPersistentMap meta){
try{
if(meta != null && ADD_ANNOTATIONS.isBound())
ADD_ANNOTATIONS.invoke(visitor, meta);
}
catch (Exception e)
{
throw Util.sneakyThrow(e);
}
}

static void addParameterAnnotation(Object visitor, IPersistentMap meta, int i){
try{
if(meta != null && ADD_ANNOTATIONS.isBound())
ADD_ANNOTATIONS.invoke(visitor, meta, i);
}
catch (Exception e)
{
throw Util.sneakyThrow(e);
}
}

private static Expr analyzeSymbol(Symbol sym) {
Expand Down
15 changes: 2 additions & 13 deletions src/jvm/clojure/lang/LazySeq.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,8 @@ public Obj withMeta(IPersistentMap meta){
final synchronized Object sval(){
if(fn != null)
{
try
{
sv = fn.invoke();
fn = null;
}
catch(RuntimeException e)
{
throw e;
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
sv = fn.invoke();
fn = null;
}
if(sv != null)
return sv;
Expand Down
18 changes: 2 additions & 16 deletions src/jvm/clojure/lang/TransactionalHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,7 @@ public V remove(Object k){
IPersistentMap map = (IPersistentMap) r.deref();
Object ret = map.valAt(k);
//checked exceptions are a bad idea, especially in an interface
try
{
r.set(map.without(k));
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
r.set(map.without(k));
return (V) ret;
}

Expand Down Expand Up @@ -157,14 +150,7 @@ public boolean remove(Object k, Object v){
if(e != null && e.getValue().equals(v))
{
//checked exceptions are a bad idea, especially in an interface
try
{
r.set(map.without(k));
}
catch(Exception ex)
{
throw Util.sneakyThrow(ex);
}
r.set(map.without(k));
return true;
}
return false;
Expand Down
43 changes: 4 additions & 39 deletions src/jvm/clojure/lang/Var.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,7 @@ public void setMeta(IPersistentMap m) {
}

public void setMacro() {
try
{
alterMeta(assoc, RT.list(macroKey, RT.T));
}
catch (Exception e)
{
throw Util.sneakyThrow(e);
}
alterMeta(assoc, RT.list(macroKey, RT.T));
}

public boolean isMacro(){
Expand All @@ -279,14 +272,7 @@ public Object getTag(){
}

public void setTag(Symbol tag) {
try
{
alterMeta(assoc, RT.list(RT.TAG_KEY, tag));
}
catch (Exception e)
{
throw Util.sneakyThrow(e);
}
alterMeta(assoc, RT.list(RT.TAG_KEY, tag));
}

final public boolean hasRoot(){
Expand All @@ -299,14 +285,7 @@ synchronized public void bindRoot(Object root){
Object oldroot = this.root;
this.root = root;
++rev;
try
{
alterMeta(dissoc, RT.list(macroKey));
}
catch (Exception e)
{
throw Util.sneakyThrow(e);
}
notifyWatches(oldroot,this.root);
}

Expand Down Expand Up @@ -397,14 +376,7 @@ public Object call() {
}

public void run(){
try
{
invoke();
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
invoke();
}

public Object invoke() {
Expand Down Expand Up @@ -745,14 +717,7 @@ public Object invoke(Object m, Object k, Object v) {
static IFn dissoc = new AFn() {
@Override
public Object invoke(Object c, Object k) {
try
{
return RT.dissoc(c, k);
}
catch(Exception e)
{
throw Util.sneakyThrow(e);
}
return RT.dissoc(c, k);
}
};
}

0 comments on commit 047ca37

Please sign in to comment.