Comments (7)
Reflection is definitely sometimes a quick way to get things working. However, since it depends on the implementation details of the library you're reflecting on, it often leads to breakages down the line. (For example, it's usually one of the main obstacles to JDK upgrades.) So the convenience and compatibility today may lead to inconvenience and incompatibility later on.
from guava.
Since GsonSerializer
is creating the Range
object, you'll have to identify who is responsible for that code and figure out how it's serializing and deserializing the new range. GsonSerializer
isn't part of Guava, so we don't have control over that.
from guava.
Since
GsonSerializer
is creating theRange
object, you'll have to identify who is responsible for that code and figure out how it's serializing and deserializing the new range.GsonSerializer
isn't part of Guava, so we don't have control over that.
ex:
public boolean hasLowerBound() { return lowerBound != Cut.belowAll(); }
When the lowerBound object is deserialized, although it is still of type com.google.common.collect.Cut.BelowAll, since it is a re-created object, it will not be equal to Cut.belowAll(). So I think this judgment is not accurate enough. Would it be more accurate to use the following judgment?
public boolean hasLowerBound() { return ! (lowerBound instanceof BelowAll) ; }
@cpovirk
from guava.
If GsonSerializer
is creating extra instances of private classes by using reflection to override visibility rules, then your suggestion would probably fix the problem you're seeing. But that is an approach that I would not want to encourage: Such reflection may cause many other such problems, and I don't want to give users false hope that it will work in general or that we're doing any kind of testing or planning to make that happen.
from guava.
If I need to pass the Range type when requesting the external interface, I first need to serialize the Range into JSON and send it to the server. Upon receiving the JSON, the server needs to deserialize it to obtain the correct Range type and perform the corresponding logical processing. However, this scenario becomes impractical because the deserialization process requires the object to be regenerated
@cpovirk
from guava.
It sounds like GsonSerializer
needs to serialize and deserialize a Range
object manually instead of using reflection. That probably means that it will need to change to use a custom serializer for Range
.
from guava.
This workaround may necessitate extra effort from the user. I think as a tool class, it is crucial to consider its convenience for users across different scenarios and its compatibility with various use cases.
from guava.
Related Issues (20)
- ArrayIndexOutOfBoundsException when creating a EntityManagerFactory HOT 1
- Support for weak values in `Multimap`
- 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
- 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
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.