lundi 10 août 2020

Reflection: different behavior when running locally and from docker

There is the following class hierarchy:

public class A {}
public class B extends A{}
public class C extends A{}

And entity hierarchy:

@Entity
@Table(name = "table_name")
@DiscriminatorValue("B")
public class HB extends HA<B> {}

@Entity
@Table(name = "table_name")
@DiscriminatorValue("C")
public class HC extends HA<C>{}


@Entity
@Table(name = "table_name")
@TypeDef(name = JsonObject.TYPE, typeClass = JsonObject.class)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorFormula(...)
public class HA<T extends A>{

  // id, constructor etc.

  @Type(type = JsonObject.TYPE)
  private T data;

}

And I have JsonObject

public class JsonObject implements UserType, DynamicParameterizedType {

  public static final String TYPE = "type";
  private Type javaType;

  // implemenations of UserType methods

  @Override
  public void setParameterValues(Properties parameters) {
    XProperty xProperty = (XProperty) parameters.get(DynamicParameterizedType.XPROPERTY);
    if (xProperty instanceof JavaXMember) {
      try {
        javaType = ((JavaXMember) xProperty).getJavaType();
      } catch (Exception ex) {
        // ...          }
    } else {
      // ...
    }
  }


}

When I run this code locally from IDE (openJdk 12), all OK. javaType has value T, and javaType instanceOf TypeVariable is true. But when I run it from docker (openjdk:12-alpine) javaType always has type com.some.package.B.

So, what could be the problem of different program behavior when launched from different environments? Maybe problem not in jdk version, but in smth else.





Aucun commentaire:

Enregistrer un commentaire