Update Yaml.LoadAs() signature to support Class<? super T> type instead of Class<T>

Issue #556 resolved
Matt D. created an issue

The issue I’m having with the current method signature is that it throws a compiler warning when passing an unparameterized class of type T. Parameterizing Class<T> is not possible without this new signature. Passing as unparameterized yields a raw type, which otherwise works fine, but is throwing a warning. Instead of suppressing it, I would rather resolve it at the public interface where the cast is already unchecked, but with the option to support parameterized types.

snakeyaml / snakeyaml / src / main / java / org / yaml / snakeyaml / Yaml.java — Bitbucket

<T> T loadAs(String yaml, Class<T> type)

would become public

<T> T loadAs(String yaml, Class<? super T> type)

etc.

Comments (8)

  1. Andrey Somov

    Unfortunately, the change is not backwards compatible (you can see it in the test). It changes the scope.

  2. Log in to comment