H
HK
Suppose a class needs data from a resource, i.e. some
file alongside in the .jar with the class file. This
data needs to be read only ever once, because it
is not about to change and is not supposed to change.
The place to read the resource (I think) is
in the static initializer of the class.
The result of getResourceAsStream() may nevertheless turn
out to be null. One reason could be that someone unpacked
the .jar and then the resource "disappeared".
The class has no way to operate properly without the data;
someone could as well have deleted the class file itself.
What is the proper Exception to throw:
a) RuntimeException (or subclass),
b) Error (or subclass),
c) something else?
Thanks,
Harald.
file alongside in the .jar with the class file. This
data needs to be read only ever once, because it
is not about to change and is not supposed to change.
The place to read the resource (I think) is
in the static initializer of the class.
The result of getResourceAsStream() may nevertheless turn
out to be null. One reason could be that someone unpacked
the .jar and then the resource "disappeared".
The class has no way to operate properly without the data;
someone could as well have deleted the class file itself.
What is the proper Exception to throw:
a) RuntimeException (or subclass),
b) Error (or subclass),
c) something else?
Thanks,
Harald.