Solved

Odd Java <init> problem..

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Better way to make a string with template variables in java 3 31
Adding multiple JVM environments to RedHat 6 7 69
How to log java errors in tomcat 8 23
Html split(text) 2 25
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

679 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