Re: Collections.class methods anachronisms?



jupiter wrote:
This passes the compiler (although the compiler does give a warning), so the code will be compiled to bytecode where it promptly emits a ClassCastException. Passing the list through to checkedList still gives an error, but it is emitted at the point of modification as opposed to the point of access (which, in some cases, might not even give an error!).
I guess I was stuck thinking "compiler means everything now" but when using references to do implicit casting, anything can happen at runtime as you've clearly shown.
This is true, but don't underestimate compiler warnings.

im
.



Relevant Pages

  • Re: Why INFINITE loop in a thread occupy so much CPU time??
    ... With the attendant warning about the constant expression. ... This is a common programming technique. ... Good programming practice would consist of using the compiler at ... One can write 'bool' in C++ but not C. ...
    (microsoft.public.vc.mfc)
  • Re: help needed please!
    ... But some compilers like to give you a warning ... Each warning a compiler can give you is important when you not ... but you may use flages to handle flags to handle flags when you ... >> stdout is line bufferd and until one or both of the following cases is ...
    (comp.lang.c)
  • Re: Overloading abstract methods
    ... I'm calling this abstract class ResumeWriter. ... > use of in each subclass is up to you. ... >> However, if I do that, I get compiler warnings that the parameters for ... Disable that warning. ...
    (comp.lang.java.programmer)
  • Re: Portability / compatibility issues
    ... I have posted my test code below, and the results I get on each compiler. ... The crux of the matter is that the 'strstr' function differs wildly in its behaviour on different platforms, and precious few man pages will actually provide a worked example of any function, let alone this one. ... I have had to write the "has_slash" function and use the reserved work SLASH already, to get around the problems that strstrgives me. ...
    (comp.lang.c)
  • Re: Developer poll. return within finally: I need your opinons
    ... > example) but the compiler still raises the warning. ... Section 14.1 of the Language Spec covers normal vs. abrupt ... unwise to write code whose correct interpretation by another human ...
    (comp.lang.java.programmer)