You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an expression is used to calculate a value which is then assigned to a local variable, a field, a method call argument, the expected return type of the expression should be assignment compatible with the type of the variable, field, or method parameter.
Unfortunately, getting the type of an expression is not simple. Most likely, this requires byte code and data flow analysis.
Example:
Class A has a static method "write" with a parameter of interface type java.io.Serializable.
Class B calls A.write(new DataObject()).
The expression new DataObject() returns a value of type DataObject.
In order for this code to work, the class type DataObject must implement the interface Serializable.
The byte code for the above logic would first create an instance of class DataObject, put a reference to this object onto the stack, call its constructor (<init>()), and then call the method A.write(Serializable) which will take the reference for the argument from the stack. This means that stack analysis is required to find the actual type of the argument value.
The text was updated successfully, but these errors were encountered:
If an expression is used to calculate a value which is then assigned to a local variable, a field, a method call argument, the expected return type of the expression should be assignment compatible with the type of the variable, field, or method parameter.
Unfortunately, getting the type of an expression is not simple. Most likely, this requires byte code and data flow analysis.
Example:
A
has a static method "write" with a parameter of interface typejava.io.Serializable
.B
callsA.write(new DataObject())
.new DataObject()
returns a value of typeDataObject
.DataObject
must implement the interfaceSerializable
.The byte code for the above logic would first create an instance of class
DataObject
, put a reference to this object onto the stack, call its constructor (<init>()
), and then call the methodA.write(Serializable)
which will take the reference for the argument from the stack. This means that stack analysis is required to find the actual type of the argument value.The text was updated successfully, but these errors were encountered: