Issue Details (XML | Word | Printable)

Key: JAVA3D-585
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: mcneillk
Reporter: mcneillk
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
java3d

ClassCastException in TransformStructure.java

Created: 27/May/08 06:24 AM   Updated: 28/May/08 08:50 AM   Resolved: 28/May/08 08:50 AM
Component/s: j3d-core
Affects Version/s: 1.5.1
Fix Version/s: not determined

Time Tracking:
Not Specified

File Attachments: 1. Java Source File TransformStructure.java (25 kB) 28/May/08 05:15 AM - mcneillk

Environment:

Operating System: All
Platform: All


Issuezilla Id: 585
Tags:
Participants: jada, kcr and mcneillk


 Description  « Hide

There is a simple ClassCastException that occurs in TransformStructure because
one of the messages is not an Object[], it's a List:

// 433
for (int i = 0; i < oSize; i++) {
Object[] nodes = (Object[]) objectList.get;
if (J3dDebug.devPhase && J3dDebug.debug) { J3dDebug.doDebug(J3dDebug.transformStructure, J3dDebug.LEVEL_5, "vwcBounds computed this frame = " + nodes.length + "\n"); }

Exception in thread "J3D-TransformStructureUpdateThread-1"
java.lang.ClassCastException: java.util.ArrayList cannot be cast to
[Ljava.lang.Object;
at
javax.media.j3d.TransformStructure.processGeometryAtomVwcBounds(TransformStructure.java:440)
at javax.media.j3d.TransformStructure.processMessages(TransformStructure.java:187)
at javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.java:102)
at javax.media.j3d.J3dThread.run(J3dThread.java:275)

This is the result of a code path apparently not traversed very often, but the
fix is easy, and tested to work:

for (int i = 0; i < oSize; i++) {
Object[] nodes = null;
if (objectList.get instanceof List) { nodes = ((List)objectList.get(i)).toArray(); } else { nodes = (Object[]) objectList.get(i); }

This fix is low risk, and I would really like to see it in 1.5.2. Please provide
feedback.



kcr added a comment - 27/May/08 12:50 PM

We'll take a look in the next day or two. For a very safe fix, such as this
appears to be, there may still be time to integrate it.


mcneillk added a comment - 28/May/08 05:13 AM

I found a better (and more compact) way to fix this issue so that the code
remains consistant. It involves simply appending "toArray()" to the call that
was adding a List where it sould be adding a Object[].

objectList.add(g.mirrorGroup.toArray());

-DIFF-

Index: TransformStructure.java
===================================================================
RCS file: /cvs/j3d-core/src/classes/share/javax/media/j3d/TransformStructure.java,v
retrieving revision 1.9
diff -u -r1.9 TransformStructure.java
— TransformStructure.java 28 Feb 2008 20:17:32 -0000 1.9
+++ TransformStructure.java 28 May 2008 12:06:10 -0000
@@ -598,7 +598,7 @@
if (m.args[0] instanceof GroupRetained) {
GroupRetained g = (GroupRetained) m.args[0];
if (g.mirrorGroup != null) { - objectList.add(g.mirrorGroup); + objectList.add(g.mirrorGroup.toArray()); }
} else {
Object[] gaArray = (Object[]) m.args[0];


mcneillk added a comment - 28/May/08 05:15 AM

Created an attachment (id=364)
Patched source from CVS


mcneillk added a comment - 28/May/08 05:24 AM

Marking as "started" as per standard procedure.


mcneillk added a comment - 28/May/08 05:24 AM

Ready to integrate.


jada added a comment - 28/May/08 07:12 AM

Great! Your earlier fix is safe, but this is the preferred fix as it uses the
same pattern within j3d in passing message. I will integrate it today if there
isn't other issue pop up.


kcr added a comment - 28/May/08 07:40 AM

In fact, Chien and I took a quick look yesterday and were going to suggest the
exact fix you came up with most recently.


jada added a comment - 28/May/08 08:50 AM

Integrated. Thanks!