• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

error not caught at compile or runtime

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I asked this question in the beginner's forum and people seem to think I am crazy, so I'll try here. This is a problem out of Scott's "Programming Language Pragmatics". Can anyone one give me an example of an error in Java that would not be caught at compile time or run-time. I'm not talking about a logical error but a violation of the language definition, ie. a syntactic or semantic... or I guess even lexical error. Any input would be deeply appreciated.
Thanks,
Thomas
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one that was caught and silently absorbed ?
e.g. this idiom is quite common

this should be handled like this instead :

D
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there's this favorite:

The programmer surely meant to write "b == true" but since the result of the assignment is a boolean, the compiler misses this error. This can happen in C/C++ much more often, because C doesn't have a boolean type. There's an easy way to avoid this problem by the way: never compare to a boolean literal. The above condition could be written "if (b)" and the error then would never happen.
 
Thomas White
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Don and Ernest
Thanks for the examples. Don are you saying that writing a catch block with no code to handle the exception might be considered a flaw in the language spec?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic