Reputation: 1651
Is there a way to change the properties of an imported class in eclipse? Specifically, I am trying to change the serialVersionUID
property
Upvotes: 1
Views: 54
Reputation: 817
The only reason to change the serialVersionUID is if you want to purposely break compatibility with all existing serializations or if incompatible changes are made to the structure of the class. Heres a list of incompatible changes.
But if you need to change it, you can generate the serialVer your jvm is probably using using the serialver tool:
serialver -classpath whatever com.foo.bar.MyClass
Manually set the serialVerUID in your class and it should match and be able to load, assuming you haven't changed the class in such a way as to invalidate. Hope this helps
Upvotes: 2
Reputation: 1112
If the code of the imported class is compiled, then no. The serialVersionUID
property is of type long
, and cannot be changed.
You can, however, cast it to any type you'd like, as long as it's feasible. If it's not, you can convert it.
Upvotes: 0