Re: finalize()



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?
-----------

.



Relevant Pages

  • Re: C# Reflection--anybody use it lately?
    ... public void DoSomething() ... public void DoSomethingElse() ... This AOP approach only uses reflection during compile time and not runtime, additionally I will say that if you think AOP is only related to security then either that URL is no good or you misunderstood it. ... Tut tut. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: finalize()
    ... public void doSomething() throws Exception { ... File file = null; ... You failed to catch the Exception that doSomethingmight throw. ...
    (comp.lang.java.programmer)
  • Re: extending class that is not in a packed
    ... Now I am using reflect to extend this class ... >> public void DoSomething(){ ... >> and class Class2 that is ... >> public void DoSomething2(){ ...
    (comp.lang.java)
  • Re: runtime stack
    ... The stack would be relevant if you were concerned about the number of variables you are using within a method. ... public void FirstTry(string varone){if ... dosomething();} ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how TcpLinstenr is fired in windows service
    ... Hi Vadyam Stetsyak, ... The above code raise one exception In listner method TcpListner.start ... >> private TcpListener tcpListener; ... >> public void Start ...
    (microsoft.public.dotnet.languages.csharp)