Comments (4)
While it would be convenient to have a public constructor for HashBasedTable to support easier serialization and deserialization, it's important to note that the Guava library designers have intentionally chosen not to expose a public constructor for HashBasedTable. This design decision is likely due to the complexity and internal structure of the table, and they may have considered it safer to provide factory methods for creating instances.
If you still wish to have a public constructor for HashBasedTable, you could consider creating a wrapper class that extends HashBasedTable and exposes the constructor you need. This way, you can have a deserialization-friendly class while still keeping the internal implementation of HashBasedTable encapsulated.
from guava.
Could you say a bit more about the problem you are seeing? It should normally be possible to serialize and deserialize a HashBasedTable
, as verified by this test. Are we talking about something other than Java Serialization?
A code sample that shows the problem would help us understand it.
If you still wish to have a public constructor for HashBasedTable, you could consider creating a wrapper class that extends > HashBasedTable and exposes the constructor you need.
Unfortunately that isn't possible as such. HashBasedTable
doesn't have a visible constructor, so it can't be subclassed. But it would be possible to make a wrapper class that contains a HashBasedTable
and use that for the serialization and deserialization. The ForwardingTable
class would be useful for this.
from guava.
In general, these days Guava follows the guidance of Effective Java item 74 (2d edition; item 85 in the 3d edition): "Prefer alternatives to Java serialization". (Guava's "important warnings", item 4, is a consequence of this.)
Basically, Java serialization is fragile (because it depends on details of internal implementation which may change) and we don't recommend using it. This is why (for instance) the common.graph types we released several years ago don't implement Serializable.
from guava.
Closing for lack of response. @Dynasty-develop feel free to reopen if there is more to say.
from guava.
Related Issues (20)
- debug android HOT 1
- Addition of Built-In Methods for Primitive Math operations HOT 1
- Could not find error_prone_annotations-2.11.0.jar HOT 1
- Gradle 6.x isn't able to pick right Guava variant HOT 3
- Guava build fails on `master` with JDK 21 HOT 4
- Add action version comments in GitHub workflow files HOT 1
- Supply Chain Security
- Is `com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava` really necessary? HOT 2
- SmoothRateLimiter.SmoothBursty obtaining too many permits without failure HOT 1
- Certain versions of Guava on Maven central no longer working on Java 11 HOT 2
- guava-gwt should publish Gradle module metadata or somehow fix POM HOT 2
- java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkState(boolean, java.lang.String, long) HOT 1
- `Suppliers.memoize()` thread pinning HOT 6
- Copying a filtered collection with ImmutableSet.copyOf() should require visiting each element only once HOT 1
- com.google.common.collect.Range#hasLowerBound determination error after deserialization HOT 7
- InternetDomainName.topPrivateDomain() throws exception for Amazonaws-Domain HOT 4
- Use Gradle module available-at tag instead of files for redirecting jre vs android consumers HOT 5
- Failing while building guava version v31.0.1 using mvn clean install HOT 3
- Make `Striped.custom` public HOT 2
- Improve `guava-android` Animal Sniffer compatibility testing for Java 8+ APIs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guava.