lundi 16 janvier 2017

org.reflections.Reflections cannot find my class (in relation the way I'm writing my lambda)

I'm working with GATK, a java tool for bioinformatics. It use org.reflections.Reflections under the hood to load some plugins.

My plugin compiled but wasn't found/loaded by GATK while it was in the classpath and a similar tool was working without any problem. By removing some part of the code, I've narrowed the problem to the following line which was the cause of my problem (see filter ) :

(...)
ctx.getAlleles().stream().filter(T->!(T.isSymbolic() || T.isNoCall())).mapToInt(new ToIntFunction<Allele>() {
    public int applyAsInt(Allele value) {return value.length();};
    });
(...)

My plugin is loaded if I change the line above to :

(...)
ctx.getAlleles().stream().mapToInt(new ToIntFunction<Allele>() {
        public int applyAsInt(Allele value) {return value.length();};
    });
(...)

It's also loaded if the line is:

final Predicate<Allele> afilter = new Predicate<Allele>() {
    @Override
    public boolean test(Allele a) {
        return !(a.isNoCall() || a.isSymbolic());
    }
};
ctx.getAlleles().stream().filter(afilter).mapToInt(new ToIntFunction<Allele>() {
        public int applyAsInt(Allele value) {return value.length();};
    });

why ?





Aucun commentaire:

Enregistrer un commentaire