Array declaration compiler bug?

  • Thread starter Kenneth P. Turvey
  • Start date
K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I noticed today that a program I've written has different behavior when
one of the variables is declared as:

int outPixel[]

instead of

int[] outPixel

Shouldn't these exhibit exactly the same behavior all the time?


- --
Kenneth P. Turvey <[email protected]>

XMPP IM: (e-mail address removed)
Yahoo IM: kpturvey2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEOHhgi2ZgbrTULjoRAlp0AJ9KLd/X03mV/K5hXQW/PBa0OARk9wCeL9oI
CCrmXqAYcEKJRlv1kxTsCig=
=XKhh
-----END PGP SIGNATURE-----
 
P

Patricia Shanahan

Kenneth said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I noticed today that a program I've written has different behavior when
one of the variables is declared as:

int outPixel[]

instead of

int[] outPixel

Shouldn't these exhibit exactly the same behavior all the time?

It is very difficult to say from a code snippet. For example:

int outPixel[],y;

and

int[] outPixel,y;

are different. Can you produce a complete, self-contained example?

Patricia
 
K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It is very difficult to say from a code snippet. For example:

int outPixel[],y;

and

int[] outPixel,y;

are different. Can you produce a complete, self-contained example?

Yes, I understand the difference of that above. I'll see if I can get
something small to work over the next week and post something at that
time. The complete statement was:

int[] outPixel = new int[]{0, 0, 0};

and

int outPixel[] = new int[]{0, 0, 0};

This was followed by a looping construct that works fine for the first
line, but seems to use a newly initialized array for each iteration when
the second declaration is used.

The scoping is all wrong.

- --
Kenneth P. Turvey <[email protected]>

XMPP IM: (e-mail address removed)
Yahoo IM: kpturvey2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEOJmTi2ZgbrTULjoRAqE2AKDDw6W3bd6EAyufOQyTpjwJ4a89zgCgryjz
oP2i/SR0nO/MMz+K0LnsGrw=
=qhaz
-----END PGP SIGNATURE-----
 
M

Mike Schilling

Kenneth P. Turvey said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It is very difficult to say from a code snippet. For example:

int outPixel[],y;

and

int[] outPixel,y;

are different. Can you produce a complete, self-contained example?

Yes, I understand the difference of that above. I'll see if I can get
something small to work over the next week and post something at that
time. The complete statement was:

int[] outPixel = new int[]{0, 0, 0};

and

int outPixel[] = new int[]{0, 0, 0};

This was followed by a looping construct that works fine for the first
line, but seems to use a newly initialized array for each iteration when
the second declaration is used.

The scoping is all wrong.


If that's really the only difference, you might try disassembling the
resulting code with javap -c and seeing if that gives you any clues.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Java 1.6 13
Beowulf clusters 9
Parameters (command line, preferences, user input) 1
Logger performance 5
Simple GUI problem 1
Executor 8
Logger performance 3
Binomial Simulation 16

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top