Bug 21518 - Debugger source lookup problem when debugging against Wireless Toolkit (WTK) 1.04
Summary: Debugger source lookup problem when debugging against Wireless Toolkit (WTK) ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-12 04:15 EDT by christian.scheer CLA
Modified: 2002-08-01 10:32 EDT (History)
1 user (show)

See Also:


Attachments
workspace to reproduce problem (11.45 KB, application/zip)
2002-07-12 04:16 EDT, christian.scheer CLA
no flags Details
patch launching plug-in (193.36 KB, application/octet-stream)
2002-08-01 09:05 EDT, Darin Wright CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description christian.scheer CLA 2002-07-12 04:15:00 EDT
!MESSAGE Invalid path: 
java/lang/k:/re/midp/MIDP1/0/3/src/share/classes/java/lang/Class.java
The bug is related to #12966 

Steps to reproduce:

Unzip the attached ManyBalls.zip into your workspace directory. "Import existing 
project into Workspace"
Adjust the Java Build Path for the project to include <wtk home>\lib\midpapi.zip
Get the stampysoftanttasks.jar from www.stampysoft.com, put it in the 
plugin\org.apache.ant directory and add the following lines to the plugin.xml

<library name="stampysoftanttasks.jar">
      <export name="*"/>
</library>

Edit the build.xml to match the 2jmewtk.home property your WTK path

Edit the two .cmd files to point to the correct WTK path/Eclipse installation
Run the build task
Verify the build by running the runjad.cmd

Set a breakpoint in ManyBalls.startApp()
Run the rundbg.cmd batch file
Attach to the Emulator (port 5000)
The emulator should show a blank screen
In the debugger select the System Thread[KVM_main] and suspend it
The Debugger Source Lookup should pop up, asking for the source of 
java.lang.Class. 
At this point the entry gets written to the .log
Comment 1 christian.scheer CLA 2002-07-12 04:16:56 EDT
Created attachment 1691 [details]
workspace to reproduce problem
Comment 2 Jared Burns CLA 2002-07-12 15:37:19 EDT
Can you provide a test case that doesn't require stampysoftanttasks? I expect 
it would be a real hassle (legal red tape) for me to acquire a copy of it.
Comment 3 christian.scheer CLA 2002-07-14 06:03:40 EDT
You can do w/out the stampysoft ant tasks:

- In the project root directory, execute the 
following command:
\<wtkhome>\bin\preverify -classpath bin;<wtkhome>\lib\midpapi.zip 
bin

- Add the .class files from the output folder to the ManyBalls.jar

Regarding your 
concerns about the license:
quote from the stampysoft site: "This code is released under the 
MIT license, which means you can do just about anything other than sue me."

I should add that 
the midpapi.zip file that ships with the WTK contain class files with fully qualified paths for 
the SourceFile entries that cause this error to appear.
Comment 4 Vickie Yang CLA 2002-07-24 21:43:11 EDT
I just found the description of SourceFile Attribute in the VM Spec like below: 
The value of the sourcefile_index item must be a valid index into the 
constant_pool table. The constant pool entry at that index must be a 
CONSTANT_Utf8_info structure representing the string giving the name of the 
source file from which this class file was compiled. 
Only the name of the source file is given by the SourceFile attribute. It never 
represents the name of a directory containing the file or an absolute path name 
for the file. For instance, the SourceFile attribute might contain the file 
name foo.java but not the UNIX pathname /home/lindholm/foo.java.

However, the sourefile name of the class in midpapi.zip of WTK contained an 
absolute path name, such as 
k:/re/midp/MIDP1/0/3/src/share/classes/java/lang/Class.java.
I really don't know how to get such class file using javac.
Comment 5 Darin Wright CLA 2002-07-29 16:01:00 EDT
There is code in the Java source locator to handle this, but perhaps it is 
failing on Linux:
	// @see bug# 12966 - remove absolute path prefix
	int index = sourceName.lastIndexOf(File.pathSeparatorChar);
	if (index >= 0) {
		sourceName = sourceName.substring(index + 1);
	}

Jared, what is "File.pathSeparatorChar" on Linux? Perhaps it does not match the 
class files (which could have been compiled on a different platform). In this 
case, I suppose we need to look for any valid path seperator.
Comment 6 Vickie Yang CLA 2002-07-30 23:45:14 EDT
I don't think "File.pathSeparatorChar" would be the cause, since it depends on  
JDK of different platforms.
Comment 7 christian.scheer CLA 2002-07-31 03:02:28 EDT
I guess Darin meant this: If the .class file was build under linux, it would 
contain "/". Checking under Windows against File.pathSeparatorChar, which is "\" 
would never yield a match. However, the files in question contain a 
strange mixture of drive letters ("k:") and unix style separators.
Chris
Comment 8 Jared Burns CLA 2002-07-31 10:01:19 EDT
Christian, can you cite a specific classfile in the midpapi.zip that contains 
a fully qualified path? I unzipped the zip file and opened a few of the 
classfiles and I don't see a problem. For example, the "SourceFile" attribute 
in com.sun.cldc.i18n.StreamReader.class is "StreamReader.java"
Comment 9 christian.scheer CLA 2002-07-31 10:16:20 EDT
Jared,

java.io.DataInput.class
A binary dump of the file looks like this (removed unprintable chars by hand)

readFully([B)VExceptions([BII)VskipBytes(I)IreadBoolean()ZreadByte()BreadUnsigne
dByte()IreadShort()SreadUnsignedShort readChar()CreadInt readLong ()J readUTF 
()Ljava/lang/String; SourceFile 
:k:/ws/toolkit/1.0.3-fcs/kvm/api/src/java/io/DataInput.java java/io/DataInput 
java/lang/Object java/io/IOException

Chris
Comment 10 Jared Burns CLA 2002-07-31 10:36:05 EDT
We seem to have version 1.0.4 of the toolkit:
[jburns@radiohead bin]$ ./emulator -version
J2ME Wireless Toolkit 1.0.4
Profile: MIDP-1.0
Configuration: CLDC-1.0

My java.io.DataInput.class has a SourceFile of "DataInput.java"

The path in your classfile seems to indicate that you're running version 
1.0.3. Can you try upgrading to see if they fixed this bug in 1.0.4?

If we want to workaround the bug, Darin's suggestion seems correct. We 
should check for '/' or '\'.
Comment 11 christian.scheer CLA 2002-07-31 11:15:35 EDT
I checked against a real 1.04 version, same result. 
But you are running on linux, whereas I use 
windows. So there seem to be different midpapi.zip depending on the OS. 

Microsoft Windows 
2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft 
Corp.

d:\Programs\java\wtk104\bin>emulator -version
J2ME Wireless Toolkit 
1.0.4
Profile: MIDP-1.0
Configuration: CLDC-1.0

 Verzeichnis von 
D:\Programs\java\wtk104\lib

09.07.2002  21:21       <DIR>          .
09.07.2002  21:21       <DIR>          
..
09.07.2002  19:25               64.604 emptyapi.zip
13.06.2002  10:27                1.513 
internal.config
13.06.2002  10:20              526.598 midpapi.zip
13.06.2002  10:27                  932 
system.config
Comment 12 Darin Wright CLA 2002-07-31 11:32:04 EDT
I suggest to create a patch looking for both "slashes", and provide to Chris 
for testing.
Comment 13 Darin Wright CLA 2002-08-01 09:05:11 EDT
Created attachment 1781 [details]
patch launching plug-in
Comment 14 Darin Wright CLA 2002-08-01 09:06:39 EDT
Attached is a test replacement for "org.eclipse.jdt.launching".
Comment 15 christian.scheer CLA 2002-08-01 10:06:07 EDT
Tried attachment, seems to fix the problem.
Comment 16 Darin Wright CLA 2002-08-01 10:26:18 EDT
Released the fix to HEAD and 2.0.1 Branch
Comment 17 Darin Wright CLA 2002-08-01 10:32:49 EDT
Marking as verified (via Chris)