This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [RFA/JDWP] Fix ReferenceType.sourceFile
- From: Kyle Galloway <kgallowa at redhat dot com>
- To: Kyle Galloway <kgallowa at redhat dot com>
- Cc: GCJ-patches <java-patches at gcc dot gnu dot org>
- Date: Thu, 12 Apr 2007 10:47:41 -0400
- Subject: Re: [RFA/JDWP] Fix ReferenceType.sourceFile
- References: <461D1800.9050106@redhat.com> <461D1825.5070502@redhat.com>
Kyle Galloway wrote:
Kyle Galloway wrote:
Currently, since it is possible to get null returned from
_Jv_GetInterpClasssourceFile if the class in either native of if the
information is not available, a call to ReferenceType.sourceFile may
cause a NPE in writeString which will crash the communication thread
causing the VM to stop responding to commands. This patch fixes this
by checking in VMVirtualMachine::getSourceFile to see if there source
file is null, and throwing an AbsentInformationException. Though
there are two possible causes for this in our implementation, the
JDWP spec does not distinguish and only allows for an
ABSENT_INFORMATION error in this case.
ChangeLog
2007-04-11 Kyle Galloway <kgallowa@redhat.com>
* gnu/classpath/jdwp/natVMVirtualMachine.cc (getSourceFile): Check
for null source file and throw an exception indicating this.
Questions/comments/concerns?
Thanks,
Kyle
I realized this morning I made a typo and diffed to aousrcefile.patch,
then submitted the wrong patch. Here is the correct version with the
header included. Sorry about that.
- Kyle
Index: libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc
===================================================================
--- libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc (revision 123715)
+++ libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc (working copy)
@@ -46,6 +46,7 @@
#include <gnu/classpath/jdwp/event/filters/IEventFilter.h>
#include <gnu/classpath/jdwp/event/filters/LocationOnlyFilter.h>
#include <gnu/classpath/jdwp/event/filters/StepFilter.h>
+#include <gnu/classpath/jdwp/exception/AbsentInformationException.h>
#include <gnu/classpath/jdwp/exception/InvalidFrameException.h>
#include <gnu/classpath/jdwp/exception/InvalidLocationException.h>
#include <gnu/classpath/jdwp/exception/InvalidMethodException.h>
@@ -647,7 +648,14 @@
gnu::classpath::jdwp::VMVirtualMachine::
getSourceFile (jclass clazz)
{
- return _Jv_GetInterpClassSourceFile (clazz);
+ jstring file = _Jv_GetInterpClassSourceFile (clazz);
+
+ // Check if the source file was found.
+ if (file == NULL)
+ throw new exception::AbsentInformationException (
+ _Jv_NewStringUTF("Source file not found"));
+
+ return file;
}
void