This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 26600 - IllegalMonitorStateException at org.netbeans.ProxyClassLoader.smartLoadClass()
Summary: IllegalMonitorStateException at org.netbeans.ProxyClassLoader.smartLoadClass()
Status: CLOSED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC OS/2
: P3 blocker (vote)
Assignee: _ gtzabari
URL:
Keywords:
: 25871 26769 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-08-19 04:33 UTC by _ gtzabari
Modified: 2008-12-23 10:43 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2002-08-19 04:33:06 UTC
dev build 200208160100
IBM JDK 1.3.1

Annotation: Exception occurred in Request Processor
java.lang.IllegalMonitorStateException: JVMLK001:
current thread not owner
        at
org.netbeans.ProxyClassLoader.smartLoadClass(ProxyClassLoader.java(Compiled
Code))
        at
org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java(Compiled
Code))
        at
java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled
Code))
        at
java.lang.ClassLoader.defineClass0(Native Method)
        at
org.netbeans.JarClassLoader.simpleFindClass(JarClassLoader.java(Compiled
Code))
        at
org.netbeans.JarClassLoader.simpleFindClass(JarClassLoader.java(Compiled
Code))
        at
org.netbeans.ProxyClassLoader.smartLoadClass(ProxyClassLoader.java(Compiled
Code))
        at
org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java(Compiled
Code))
        at
java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled
Code))
        at
org.netbeans.modules.cvsclient.versioning.JavaCvsVersioningSystem.initListeners(JavaCvsVersioningSystem.java:130)
        at
org.netbeans.modules.cvsclient.versioning.JavaCvsVersioningSystem.<init>(JavaCvsVersioningSystem.java:118)
        at
org.netbeans.modules.cvsclient.NbJavaCvsFileSystem$5.run(NbJavaCvsFileSystem.java:1100)
        at org.openide.util.Task.run(Task.java:136)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:599)
Comment 1 _ ttran 2002-09-03 21:15:21 UTC
-> pnejedly.  Not sure if it has anything to do with patching bytecode.

Note: no line numbers in stack trace :-(
Comment 2 Jesse Glick 2002-09-04 01:01:48 UTC
Especially exciting exception, seeing as there are no synchronized
statements in this method at all.

Gili, is this reproducible?
Comment 3 _ gtzabari 2002-09-04 01:19:35 UTC
Reproducable? Not exactly.. I got it randomily while using JavaCVS. I
will most probably run into it again within the following days and
follow up.

BTW:

- Note the dev build where this bug was reproduced, there might have
been synchronization blocks then (?)

- If your code makes use of built-in JVM classes which are not
thread-safe (such as SimpleDateFormat, for example) you could end up
seeing this error.
Comment 4 Petr Nejedly 2002-09-04 09:20:32 UTC
OK, boys, I've read the Javadocs for ya ;-)
It can't be caused by using any thread unsafe class.
It can't be caused by presence of "synchronized", but it can
(only) be caused by the absence of "synchronized.

IMSE is thrown if you call any version of wait() or notify*()
on an object you don't have locked.
This will throw IMSE:
public class MonitorTest {
    public static void main(String[] args) {
        "Test".notify();
    }
}

This will not throw IMSE:
public class MonitorTest2 {
    public static void main(String[] args) {
        synchronized("Test") {
            "Test".notify();
        }
    }
}

Please note there is no wait or notify in the whole ProxyClassLoader
and its superclasses.

The "JVMLK001" seems very suspicious to me...
Comment 5 Petr Nejedly 2002-09-04 09:46:10 UTC
*** Issue 26769 has been marked as a duplicate of this issue. ***
Comment 6 _ gtzabari 2002-09-04 12:39:17 UTC
NOTES: 

- "JVMLK001" is a JVM-specific message, doesn't mean much (looks like
it refers to a "JVM lock")

- Contrary to your last message, it is quite possible to get a
IllegalMonitorStateException by calling a thread-unsafe class. The
difference is that you'd probably see that class in the stacktrace and
in this case we don't so our code is probably responsible, not some
3rd party class.
Comment 7 Petr Nejedly 2002-09-05 07:13:42 UTC
Be concrete. How can I get IllegalMonitorStateException by calling
"thread unsafe class"? What do you mean by that term.
If you mean totally unsynchronized class (Like, say, ArrayList),
all I can get is a race condition and corrupted data but not IMSE
as there is *no monitor* that can be in illegal state.

Please read the Javadoc for IllegalMonitorStateException,
you should get it only by calling Object.notify(), Object.notifyAll(),
Object.wait() while not owning the objects lock (i.e. out of the
synchronized section).
If it is thrown elsewhere, it is JVMs fault.
Comment 8 _ gtzabari 2002-09-05 13:44:51 UTC
All I know is that when I accessed the same SimpleDateFormat from
multiple threads simultaneously I got this error and once I
synchronized the error went away. The stacktrace pointed to a line
*inside* SimpleDateFormat. Not exactly sure why this is. Anyway, you
can ignore this case if you wish and simply rely upon the case
discussed in the Javadoc since the case I'm discussing doesn't seem to
be relevant to this specific issue.
Comment 9 Jesse Glick 2002-09-05 18:40:56 UTC
"All I know is that when I accessed the same SimpleDateFormat from
multiple threads simultaneously I got this error and once I
synchronized the error went away." - in that case it seems clear to me
that the JVM is broken. Did you report a bug about it?

What remains is to figure out why NB code might be triggering this JVM
bug and what we might be able to do about it. I have no suggestions
yet, since I am not aware of anything wrong with our code, or even
anything particularly fishy in what it is doing (as far as threading
goes).
Comment 10 _ gtzabari 2002-09-05 23:17:05 UTC
I did not file a bug against the JVM because I was doing something
explicitly forbidden: allowing multiple threads to access the same
SimpleDateFormat object. The error might not have been what I wanted
it to be but I'm pretty sure Sun would have closed it off as a "user
at fault" error.

As per your code, if you want you can you email me a copy and I'll try
to help you with it.
Comment 11 Jesse Glick 2002-09-05 23:31:23 UTC
"I was doing something explicitly forbidden: allowing multiple threads
to access the same SimpleDateFormat object." - yes, this is a user
error, and the SimpleDateFormat class is permitted to behave
unpredictably if you try to do this. However (as far as I know) the
JVM is at fault for throwing IMSE, which is only supposed to be thrown
as a result of using wait() or notify() without a lock. For the IBM
1.3 VM to throw it under other conditions probably violates the JLS.

The question is still open what these "other conditions" actually are.
Comment 12 Jesse Glick 2002-09-06 00:24:49 UTC
FWIW I just tried IBM JDK 1.3.1 on my Linux box with a current dev
build, and had no problems, incl. using JavaCVS. Suggest this be
marked WORKSFORME unless there is a definite way to reproduce the
exception.
Comment 13 _ gtzabari 2002-09-06 03:55:56 UTC
I'd like you to quickly review the function in question --
org.netbeans.ProxyClassLoader.smartLoadClass() -- for any signs of
anything that could cause a IMSE. If you can't find anything feel free
to close the issue; I will reopen it if I see this in any future builds.
Comment 14 Petr Nejedly 2002-09-09 10:05:14 UTC
There's nothing suspicious in the ProxyClassLoader and the problem
never occured during long usage of ProxyClassLoader.

Note: There are only few IMSEs in the whole issuezilla,
most of them filled by you lately, nonreproducible and at impossible
places. I bet your JVM is broken.
Comment 15 _ gtzabari 2002-10-14 02:49:54 UTC
FYI, I've made more headway on this issue.. The exception quoted by
ide.log was misleading and points to the wrong piece of code. What's
actually happening is that an IllegalMonitorException is being thrown,
caught and another exception is being thrown in its place using the
original IMSE's getMessage() for its own message. The result is that
the message still reads: "IllegalMonitorStateException" but the
stackTrace actually leads you to the second exception, not the first.

    I've tracked one IMSE back to its source, although it might be a
different IMSE than the one originally reported here. I get the
following exception:


java.lang.IllegalMonitorStateException: JVMLK002: current thread not owner
	at
org.netbeans.ProxyClassLoader.loadInOrder(ProxyClassLoader.java(Compiled
Code))
	at
org.netbeans.ProxyClassLoader.smartLoadClass(ProxyClassLoader.java(Compiled
Code))
	at
org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java(Compiled
Code))
	at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
	at
org.openide.loaders.InstanceSupport.findClass(InstanceSupport.java:534)
	at
org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:132)
	at
org.openide.loaders.InstanceDataObject$Ser.instanceClass(InstanceDataObject.java:1084)
	at
org.openide.loaders.InstanceSupport.instanceCreate(InstanceSupport.java:204)
	at
org.openide.loaders.InstanceDataObject$Ser.instanceCreate(InstanceDataObject.java:1143)
	at
org.openide.loaders.InstanceDataObject.instanceCreate(InstanceDataObject.java:674)
[catch] at
org.netbeans.core.ShortcutsFolder.acceptDataObject(ShortcutsFolder.java:127)
	at
org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:484)
	at org.openide.loaders.FolderInstance.access$100(FolderInstance.java:45)
	at org.openide.loaders.FolderInstance$2.run(FolderInstance.java:456)
	at org.openide.util.Task.run(Task.java:136)
	at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:599)


   A quick scan of ProxyClassLoader.loadInOrder() doesn't seem to
reveal any cause for IMSE but I'll keep on investigating until I find
the source. This just goes to show you debugging this code isn't
necessarily so straight forward. Furthermore, I don't think it makes
sense to close a bug as WORKSFORME when the person is unable to
actually run tests against the platform in question.

   I'll let you know when I figure this one out.
Comment 16 Jesse Glick 2002-10-14 20:21:51 UTC
OK, well you seem to be the only one able to produce the bug and
conceivably find a fix, so you are the logical assignee for it. IMSE
is still illegal to throw from that location as far as I know.

Where was an exception being rethrown with just the message kept?
Comment 17 _ gtzabari 2002-10-14 21:22:10 UTC
org.openide.loaders.InstanceSupport.instanceClass(): line 148
repackages IMSE's message and rethrows it inside a ClassNotFoundException.
Comment 18 Jesse Glick 2002-10-14 22:07:23 UTC
Yes, this is so; however it (1) does not keep the same
Throwable.message, it creates a new one, (2) uses ErrorManager to
annotate the new exception with the old one, meaning that if the CNFE
is reported using ErrorManager.notify (as all exceptions in NB are
supposed to be) then both stack traces will be visible. Obviously
something here is not working, but I couldn't guess what.
Comment 19 David Strupl 2003-01-14 08:25:57 UTC
*** Issue 25871 has been marked as a duplicate of this issue. ***
Comment 20 _ gtzabari 2003-01-19 05:58:42 UTC
I haven't seen this issue in a long time. Closing as WORKSFORME.
Comment 21 Marian Mirilovic 2003-07-29 10:41:01 UTC
closing.