private transient(一)

前言

Now want to get the return type of a method of parameters. But after debugging, it is found that this type is a parameter defined in the implementation class of the interface, and the parameter private transienthas been modified.
The current situation is that you can see it, but you can't get it when you want to use it.
The code screenshot is as follows:
through the breakpoint debugging, you can see that invocationthere is a parameter resuleType and it has a value
Insert picture description here

I want to get invocationthe request or resultTypes inside to
Insert picture description here
view this class, and found that it is an interface, and it does not define these two parameters. After
Insert picture description here
looking for a long time, I found its implementation class. It is found that these two parameters are defined in it (resultType is found, request is not seen. But this is enough, because I only need resultType)
Insert picture description here
Let’s find a way to get it

认识通过 private transient 修饰的参数

Combining several articles, you will almost understand the meaning.

理解

Below is the content extracted from the above article
first part~ 来自文档1
Java's serialization provides a mechanism for persisting object instances. When persisting an object, there may be a special object data member, and we don't want to use the serialization mechanism to save it. In order to turn off serialization on a domain of a specific object, you can add the keyword transient before this domain.
transient is a keyword of the Java language, used to indicate that a domain is not part of the serialization of the object. When an object is serialized, the value of the transient variable is not included in the serialized representation, but the non-transient variable is included.

the second part~ 来自文档2
"Transient"——bai "transient", let alone whether the du translation is appropriate, the variable zhi keyword has never been used. Simply put, dao is the non-serial number of the variable defined by transient. Or give him another name like this-"Unserializable State".
For example, if a user has some sensitive information (such as passwords, bank card numbers, etc.), for security reasons, they do not want to be transmitted in network operations (mainly related to serialization operations, and local serialization caches are also applicable). The variables corresponding to these information can be defined as transient types. In other words, the lifetime of this field only exists in the memory of the caller.

the third part~ 来自文档3
The role of java's transient keyword is that bai needs to implement the Serilizable interface, and add the dao key transient before the attributes that do not need to be serialized. When the object is serialized, this attribute will not be serialized to the specified destination in.

代码中使用通过 private transient 修饰的参数

After reading some documents, I just tried forced conversion at this time.
Insert picture description here
Insert picture description here

You can see that there is value inside, and there is no error. So at this point, it's a success.

Guess you like

Origin blog.csdn.net/s1441101265/article/details/108050170