I am getting the following error when compiling a Java class in BlueJ.
AuctionManager.java uses unchecked or unsafe operations.
This error is only displayed when the following deserialization code is in one of my functions:
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(Filename));
ArrayList<AuctionItem> AuctionList = (ArrayList<AuctionItem>) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
Can I please have some information as to why this error is being displayed, and some help to use the deserialization code without the error.
First the message you get is not an error, is it a warning; it doesn't prevent you program from compiling, or running.
As for the source, it is this line:
ArrayList<AuctionItem> AuctionList = (ArrayList<AuctionItem>) in.readObject();
Since you are casting an object (readObject
returns an Object
) to a parameterized type (ArrayList<AuctionItem>
).