Solved

Odd Java <init> problem..

Posted on 2004-08-15
5
728 Views
Last Modified: 2013-11-23
I have a simple program (code below), which gives a series of odd results.

The specifics are:
1) odd error; I get an error From Eclipse when running it; (compiles fine)
   java.lang.VerifyError: Expecting a stackmap frame at branch target 44 in method Test.Composite.<init>([LTest/Component;)V
      at Test.Computer_Vis.main(Computer_Vis.java:21)
Exception in thread "main"
  This means something wrong in the constructors (<init> is a compiler built constructor method.)

Bit if I remove the loop code (marked "code-2" below), it compiles fine, but doesn't do anythign when run. The removed code is not even at the site of the reported error!
  [It may be that Eclipse is confused, it is not totally Java 1.5 ready yet, this is a Beta]

2) So, compile it under Tiger (Java 1.5) directly,
Seems to compile, but the prints in the constructors never print...? Prints in Main do, but constructors don't seem to be called.

Perhaps this is an Eclipse (Beta) bug, but if so, what is the real error? Seeral odd things here!

Thanks
------------------------------------
Code In question:

/*
 * Created on Aug 13, 2004
 *
 *
 */
package Test;

/**
 * @author guthrie
 *
 */
import java.util.*;

public class Computer_Vis {
      public static void main(String argv[]) {
 
      // Build a sample system ...
      Component computer1 =
            new Cabinet(  );
      Component computer2 =
                  new Cabinet( new Video() );
      }
}

// Base of Equipment class
abstract class Component {  }

// ----- Leaf nodes; concrete components...
class Video extends Component { }

// ------ Now the composite sub-type(s)
abstract class Composite extends Component {
   // Code-1
   List<Component> parts = new ArrayList<Component>();
   
   Composite(  ) { }
   Composite( Component  c ) { parts.add(c);}
   Composite(Component[] Cs) {
      System.out.println("Hello");
      /* for (Component c : Cs)
       *             parts.add(c);
       */
      /*  Code-2
      for (int i=0; i<Cs.length; i++ ) {
            parts.add(Cs[i]);
            }
       */
      System.out.println("Length:" + Cs.length);
      }
}

class Cabinet extends Composite {
      Cabinet()                { super(); }
  Cabinet( Component  c ) { super(c);}
  Cabinet(Component[] Cs) {      super(Cs); }
  }

   
0
Comment
Question by:guthrie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11807438
It is a bug in Eclipse, have you tried upgrading your Eclipse installation: https://bugs.eclipse.org/bugs/show_bug.cgi?id=63591
0
 
LVL 35

Accepted Solution

by:
girionis earned 250 total points
ID: 11807446
Well as the comments indicate it is a bug with the 1.5.0-beta-b31 (javaloibby alpha version of jdk1.5). From the link above:

"I think, I found the problem.  It's a bug related to 1.5.0-beta1-b31 (javalobby
alpha version).  I tried another computer where I've 1.5.0-beta1-b32c (official
beta1 I think) installed.  Now it works.  Time to upgrade my version...

You can close the bug.  Thanks for your patience :)"
0
 
LVL 22

Expert Comment

by:NovaDenizen
ID: 11810508
Maybe you should search and replace "Component" with "Test.Component".  java.awt.Component may be treated as some kind of special or optimized case in your java compilers.  I know you're not importing anything from java.awt, but it's possible the compiler's not doing the right thing.
0
 

Author Comment

by:guthrie
ID: 11812627
Yes, thanks.

I was using beta b-31.

If I download J2SE v 5.0 Beta 2, I assume this is then the latest-and-greatest, ala B32c?
Their naming is confusing; I had J2sdk-1.5, now options are
JRE1.5, and JDK1.5.

I wish that Eclipse updates would automatically pick-up various required updates as detected. I take it I don't need to upgarde Eclipse, but just the Tiger SDK.

Thanks will try it. Good job!

(PS: "Component" seems not to be a problem.)
0
 
LVL 35

Expert Comment

by:girionis
ID: 11817884
Thank you for accepting, glad I was of help :)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question