• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception doubt

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how the exception are categorized into the generated by JVM or programmatically.

for example NullPointerException comes under JVM and NumberFormatException comes under programmatically.

but i think all the exceptions are generated due to programming only.

Please clarify in what context the Exception are classified?
 
sentil kumar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please clarify my post.
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but i think all the exceptions are generated due to programming only.


Well, in a point of view, you are right. You might say that exceptions thrown by the JVM are thrown due to "bad programming", in example an ArrayIndexOutOfBoundsException, because you, the programmer, wrote code accessing a non-defined index of the array.

But that's not the heading of the original question.

The original question is asking, which exceptions are thrown by the program code (by an explicit "throw new ...()".

A programmer who tests an argument for validy (param >= 0) would write
So, IllegalArgumentException is typical programmed thrown.

If a programmer has code like
an ArrayIndexOutOfBoundsException will be thrown by the JVM. There is no explicit code of the programmer saying "throw new IndexArrayOutOfBoundException()". It is completely "done" by the JVM.
Just the same for a NullPointerException as an example.
 
sentil kumar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how the AssertionError is come under programmatically.

Actually we are not throwing the new AssertionError(expression) in our program.

i think it is thrown by JVM only.

Please clarify this.
 
Anton Uwe
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

See it as an abbreviation for something like
 
sentil kumar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Test{
public static void main(String[] a){
System.out.println("hai");
assert 1 > 3 : "no is less than 3";
}
}

D:\jdk1.5.0\bin>javap Test
Compiled from "Test.java"
class Test extends java.lang.Object{
static final boolean $assertionsDisabled;
static java.lang.Class class$Test;
Test();
public static void main(java.lang.String[]);
static java.lang.Class class$(java.lang.String);
static {};
}

so the byte code will have the logic said by Anton Uwe.

if the assert is removed from above code.the byte code is not having the assertionsDisabled boolean and all.
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic