Re: finalize()
- From: "cy" <cybirdoc@xxxxxxxxx>
- Date: 9 Feb 2007 18:12:23 -0800
thanks, grasp
so the compiler (javac) produces one error when given the following:
class File {
void close(){}
}
abstract class DoSomething {
public abstract void doIt();
public void doSomething() throws Exception {
File file = null;
try {
this.doIt();
} finally {
if(file != null) {file.close();}
}
}
}
public class Doer extends DoSomething {
public void doIt() {};
public void doSomething() throws Exception {
throw new Exception("i hope this doesn't cause any problems");
}
public static void main(String[] args) {
Doer d = new Doer();
d.doSomething();
System.gc();
}
}
----------------
error: line 26: unreported exception java.lang.Exception; must be
caught of declared to be thrown: d.soSomething():
---------------
make sense?
-----------
.
- Follow-Ups:
- Re: finalize()
- From: Lew
- Re: finalize()
- References:
- finalize()
- From: cy
- Re: finalize()
- From: Eric Sosman
- Re: finalize()
- From: grasp06110
- finalize()
- Prev by Date: Re: Does object pooling *ever* make sense?
- Next by Date: Re: finalize()
- Previous by thread: Re: finalize()
- Next by thread: Re: finalize()
- Index(es):
Relevant Pages
|