Solved

Odd Java <init> problem..

Posted on 2004-08-15
5
720 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
Java Timer (static) 9 43
custom annotations 9 39
eclipse apache tomcat admin console 52 97
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

777 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