FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 221 : NullPointerException when fetching globals from within classes extending other classes
Last modified: 2005-11-23 17:10
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
WONTFIX -
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
Zaratustra
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2005-11-23 08:21
// This code generates a NullPointerException. Using JRE 1.5.0.
public int test[]={1,2,3,4};
class TestClass
{
TestClass()
{
evaluate();
}
void evaluate()
{
if (test!=null) println("zero");
}
}
class TestClass2 extends TestClass
{
TestClass2()
{
if (test!=null) println("one");
}
void evaluate()
{
if (test!=null) println("two");
}
}
void setup()
{
// TestClass c=new TestClass(); // This works fine
TestClass2 c=new TestClass2(); // This crashes
}
Additional Comment
#1 From fry 2005-11-23 12:15
not a bug, that's just how java works.
this is a sort of textbook case on why you don't want to initialize global
variables that way, because there's no way of ensuring when they're going
to be available.