I have a multi-threaded java system (too many classes to post on this
site), and its stragely throwing an "UnsupportedOperationException".
A quick summary of what I'm doing
Class1
- contains obj
Class2
- extends class1
- funcA tries to add an obj to linkedList references as a list.
- funcB (runs from the constructor method) calls funcA
- funcC (happens to the the run() method) calls funcA
And here is the strange bit, calling funcA from FuncB has no problems.
However exactly the same function call from funcC throws the above
exception!!!
How can this be? Any ideas? Surely such exceptions are stateless
(unlike null pointer which depends on variables/system state).
Any help much appreciated, regards,
David
[adding object to list]
> And here is the strange bit, calling funcA from FuncB has no problems.
> However exactly the same function call from funcC throws the above
> exception!!!
The exception will be thrown by the List. The exact reason I can't
tell without seeing some code. Try to find code, that reproduces
the problem that is short enough to be posted here.
Regards, Lothar
--
Lothar Kimmeringer E-Mail: spam...@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
This is the actual line thats throwing the error:
this.moversToday.add(mv);
where
//public List moversToday;
//this.moversToday = new LinkedList();
//mv its just a class I made.
The strange thing is that this line runs fine when called from one
function, but returns the following exception when called from another
function:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:146)
at java.util.AbstractList.add(AbstractList.java:84)
at com.dl.bls.BLSMovers.add(BLSMovers.java:61)
at com.dl.bls.BLSLists.addMovers(BLSLists.java:21)
at com.dl.bls.BLSMQ.refreshISIN(BLS.java:161)
at com.dl.bls.BLSMQ.run(BLS.java:1145)
Any clues?
>
> Regards, Lothar
1. forcing serialization w/o Serializable flag set on in funcA?
2. adding a primitive to the list w/o casting it to the wrapping object?
Just guessing w/o code.
David Gavini <david....@digitallook.com> wrote in message
news:8dbc4bcc.0310...@posting.google.com...
Here is a bit of code:
public class BLSMovers extends Object implements Cloneable {
public List moversToday;
public BLSMovers() {
this.moversToday = new LinkedList();
}
public void add(Mover mv) {
this.moversToday.add(mv);//this is the line that throws an exception!
}
}
Exception thrown:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:146)
at java.util.AbstractList.add(AbstractList.java:84)
at com.dl.bls.BLSMovers.add(BLSMovers.java:61)
at com.dl.bls.BLSLists.addMovers(BLSLists.java:21)
at com.dl.bls.BLSMQ.refreshISIN(BLS.java:161)
at com.dl.bls.BLSMQ.run(BLS.java:1145)
Any ideas?
> Here is a bit of code:
>
> public class BLSMovers extends Object implements Cloneable {
> public List moversToday;
>
> public BLSMovers() {
> this.moversToday = new LinkedList();
> }
> public void add(Mover mv) {
> this.moversToday.add(mv);//this is the line that throws an exception!
> }
> }
>
> Exception thrown:
> java.lang.UnsupportedOperationException
> at java.util.AbstractList.add(AbstractList.java:146)
> at java.util.AbstractList.add(AbstractList.java:84)
> at com.dl.bls.BLSMovers.add(BLSMovers.java:61)
Is funcC working with a cloned version of the instance of
BLSMovers? Something must be different, because the instance
of BLSMovers throwing the exception doesn't contain a
LinkedList anymore (the stacktrace goes from BLSMovers.add
to AbstractList.add immediately).
Thanks again,
David
"VK" <school...@yahoo.com> wrote in message news:<3f9f8e8b$0$18533$9b62...@news.freenet.de>...