1

I have a project I am working on in WebSphere Integration Developer 7.0 where I am trying to reference a public method I just wrote from a different package. I have an import statement included for the class my new method is in.

When I create an instance of my class and try to call my new method, I get a standard "method 'x' is undefined for the type 'y'" compiler error, indicating my new method isn't being recognized.

What's really peculiar to me is that when I press F3 to open the declaration of my class instance, I'm taken to the class declaration in the .class file rather than the .java file. I tried calling several other non-static methods from my class instance, which were recognized and also took me to the .class file when I opened their declarations. I have my .class and .java files for this class in the same directory.

I have cleaned and rebuilt the project to see if that would have any affect, but still see the same behavior.

So my question is, why would my IDE open the class and method declarations in the .class file rather than the .java file? I've never seen that before - could that be expected behavior within WID in this case, or does that suggest a problem with my environment?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
DanHam
  • 340
  • 2
  • 17
  • I think it depends on the projects build path. Make sure the source file(`.java`) package which you are trying to access is listed in the build path and not some jar/ war which contains the `.class` of your source file. – Tirath Oct 02 '14 at 15:54

1 Answers1

2

Why the IDE opens the .class file

Because, that is what the IDE finds listed in the build path.

It is very common behaviour.

For example, lets say we have 2 projects - project F and project B.

Project `F` - front end
Project `B` - back end

Now, F depends on B for its compilation but B can be compiled independently.

So, in order to build F, we first build B and then copy the artifacts generated as part of the build in the build path of F or if we don't want to do copy/ paste, we just make F's build path point to the artifact generated by B's build.

Now, we can build F. Here, what F actually points to are a bunch of class files not the source.

And, now if we try to access any files of B from F - IDE will intelligently open the .class file(s) for us.

Tirath
  • 2,294
  • 18
  • 27
  • After moving the project with my new method (the equivalent of "Project B" from your example) to the top of the build list of my "Project F" equivalent my compiler error is resolved. Interestingly though, when I F3 to open method and class declarations for my "Project B" class, my IDE now takes me to the .java file. Does that mean the IDE is now automatically finding the source that generated the .class file and taking me directly there? – DanHam Oct 02 '14 at 17:30
  • Not sure about your project structure but to answer your question - Yes. – Tirath Oct 02 '14 at 18:00