Question about RealType.class casting

Hoping someone might have a suggestion. I have a line from the featuresets branch of imagej-ops (I know it is no longer actively developed by you guys on imagej-ops, but I still use/used it in my own work) that is compiling fine in eclipse but not maven. I think it is likely related to maven as I just redid my overgrown homebrew library and reinstalled maven (see [1]). I have eclipse and maven working off the same Java jdk1.8. Is my issue a coding problem or a configuration/version problem with maven/java? Any suggestions? Here’s the relevant code…

Class…

public abstract class AbstractOpRefFeatureSet<I, O extends RealType<O>> extends AbstractFeatureSet<I, O>

From line 125…

// make sure we have an outtype
final Class<? extends O> outType = this.outType == null ? (Class<? extends O>) RealType.class : this.outType;

When I compile with maven I get the following error on the above line of code.

[INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ imagej-ops —
.
.
.
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project imagej-ops: Compilation failure: Compilation failure:
[ERROR] /Users/jaywarrick/Public/DropBox/GitHub/imagej-ops-fork/src/main/java/net/imagej/ops/featuresets/AbstractOpRefFeatureSet.java:[125,128] incompatible types: java.lang.Class<net.imglib2.type.numeric.RealType> cannot be converted to java.lang.Class<? extends O>
[ERROR] /Users/jaywarrick/Public/DropBox/GitHub/imagej-ops-fork/src/main/java/net/imagej/ops/featuresets/AbstractOpRefCachedFeatureSet.java:[124,128] incompatible types: java.lang.Class<net.imglib2.type.numeric.RealType> cannot be converted to java.lang.Class<? extends O>

[1] mvn -version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: “mac os x”, version: “10.10.5”, arch: “x86_64”, family: “mac”

You can avoid these kinds of errors by casting through raw; e.g.:

final Class<? extends O> outType = this.outType == null ? (Class) RealType.class : this.outType;

But this is a highly unsafe cast of course. In practice, the O might not be RealType and thus RealType does not actually extend O. Due to generics erasure, this is a quasi-illusory concern, but there are cases where is can cause problems at runtime…

Thanks. That worked. Thanks for mentioning the concerns.