Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Odd Java <init> problem..

Posted on 2004-08-15
5
Medium Priority
?
731 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

705 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