UnsupportedOperationException is thrown in Java to indicate that the requested operation is not supported.
Questions tagged [unsupportedoperation]
91 questions
299
votes
9 answers
Java List.add() UnsupportedOperationException
I try to add objects to a List instance but it throws an UnsupportedOperationException.
Does anyone know why?
My Java code:
String[] membersArray = request.getParameterValues('members');
List membersList =…

FAjir
- 4,384
- 2
- 26
- 30
20
votes
1 answer
java.lang.UnsupportedOperationException: 'posix:permissions' not supported as initial attribute on Windows
I am using Java 7 File API. I wrote a class that is working fine on Ubuntu creating directories perfectly, but when I run same code on Windows then it is throwing error:
Exception in thread "main" java.lang.UnsupportedOperationException:…

mathlearner
- 7,509
- 31
- 126
- 189
9
votes
3 answers
Unsupported add/addAll operations for Map.keySet()
Regarding the Map interface:
Why does keySet() return a Set that supports the remove operation but doesn't support add() and addAll() operations?

Hicham Moustaid
- 773
- 6
- 13
7
votes
1 answer
Weird exception when using .view on list
I had quite a big list of numbers. I needed to apply some operation on them, then take only those results that satisfy some condition. The list is sequential, so once I find the number that does not satisfy the condition, I can stop looking.
I…

Rogach
- 26,050
- 21
- 93
- 172
5
votes
2 answers
java.lang.UnsupportedOperationException JavaFX ArrayList to ObservableList
I'm having trouble with Java FX i'm currently trying to serialize an object and for that i'm creating a class that convert object from javaFX to serializable object.
But when i'm trying to load back object i get
Exception in thread "JavaFX…

Romain Kraft
- 83
- 1
- 5
5
votes
0 answers
Should I throw UnsupportedOperationException in hashCode() if I never intend for my class to be used in a hash-based collection?
Is this a good design pattern to enforce a class not being used in any hash-based collection (HashMap, HashSet, etc), or could this have unintended consequences?
class DoNotUseInHashBasedCollection {
@Override
public int hashCode() {
…

F. George
- 4,970
- 4
- 20
- 38
5
votes
5 answers
How to know if List.remove() is "Unsupported"?
I have this:
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
public class ListTest {
public static void main(String[] args) {
String[] values = { "yes", "no"};
List aa =…

Ankur Agarwal
- 23,692
- 41
- 137
- 208
4
votes
1 answer
Skip Spot Bugs stack traces when features require ASM8_EXPERIMENTAL
I'm using spotbugs-maven-plugin 4.0.0 (+ spotbugs 4.0.2 dependency).
The problem is that it cannot recognize Java 14 records.
Every time when it finds a record or a class that uses that record, it prints a long stacktrace.
[INFO] >>>…

ROMANIA_engineer
- 54,432
- 29
- 203
- 199
3
votes
0 answers
Storage Access Framework: Unsupported Uri error when querying an user selected folder uri
I am testing the Storage Access Framework for my app.
In my app the user selects a folder as an access point to the filesystem for the app itself.
This method is used:
static public void openPickerForFolderSelection(Activity activity, int…

P5music
- 3,197
- 2
- 32
- 81
3
votes
1 answer
Gson throws UnsupportedOperationException on try to stringify object, which contains java.lang.Class as a field
I wrote ClassTypeAdapter, which is correct for classes, but fails when I'm trying to work with objects, which contains classes as fields.
The ClassTypeAdapter with executable main method to reproduce the problem attached.
Any ideas?
import…

PMV
- 131
- 1
- 8
3
votes
3 answers
Getting the error "java.lang.UnsupportedOperationException: empty.maxBy" while executing PySpark locally
I am building a model using RandomForestCLassifier. This is my code,
conf = SparkConf()
conf.setAppName('spark-nltk')
sc = SparkContext(conf=conf)
sqlContext =…

Aishwarya Soni
- 105
- 1
- 9
3
votes
1 answer
unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'
This is my code:
def _parse(self, text):
"""
This is the core interaction with the parser.
It returns a Python data-structure, while the parse()
function returns a JSON object
"""
# CoreNLP interactive shell cannot…

AEU
- 195
- 2
- 3
- 8
2
votes
2 answers
JavaFX problem with playing audio: Unsupported protocol "file"
I'm trying to use javafx.scene.media.AudioClip to play audio included with .jar file, but I'm constantly getting hit with this error:
Exception in thread "main" java.lang.UnsupportedOperationException: Unsupported protocol "file"
at…

kofiy
- 31
- 4
2
votes
1 answer
Modifing ObservableList through its changeListener throws UnsupportedOperationException
I was making a simple tic-tac-toe GUI-based game. To do this I used a 2D ObservableList, filled with Figures enumerator. Every move I change the value of the chosen cell to X or O and then I check if someone won or if the game ended with a draw. If…

a.2.c.4
- 51
- 1
- 5
2
votes
1 answer
Android connection error java.lang.UnsupportedOperationException
I have a problem on android studio when I try to make a connection to a mysql database
This is the code:
public Connection getMySqlConnection()
{
/* Declare and initialize a sql Connection variable. */
Connection ret = null;
try
{
…

Francesco Sparano
- 21
- 1