You can use class cast:
public static void main(String args[]) {
Object1Type a = new Object3Type();
if (a instanceof Object3Type) {
Object3Type b = (Object3Type) a;
byte[] bytes = b.value;
}
}
But it's dangerous and not recommended practice. The responsibility for cast correctness lies on a programmer. See example:
class Object3Type implements Object2Type {
byte[] value;
}
class Object4Type implements Object2Type {
byte[] value;
}
class DemoApplication {
public static void main(String args[]) {
Object1Type a = new Object3Type();
Object3Type b = (Object3Type) a; // Compiles and works without exceptions
Object4Type c = (Object4Type) a; // java.lang.ClassCastException: Object3Type cannot be cast to Object4Type
}
}
If you do it, at least check an object with the instanceof operator previously.
I'll recommend you to declare some getter in one of the interfaces (existing or new) and implement this method in the class:
interface Object1Type extends Base {
byte[] getValue();
}
interface Object2Type extends Object1Type {}
class Object3Type implements Object2Type {
byte[] value;
public byte[] getValue() {
return value;
}
}
class DemoApplication {
public static void main(String args[]) {
Object1Type a = new Object3Type();
byte[] bytes = a.getValue();
}
}