Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No way to do that, at least for now I use workaround like this (simplified):</p> <pre><code>@SuppressWarnings({"rawtypes", "unchecked"}) public class Unchecked { public static interface UncheckedDefinitions{ InputStream openStream(); String readLine(); ... } private static Class proxyClass = Proxy.getProxyClass(Unchecked.class.getClassLoader(), UncheckedDefinitions.class); public static UncheckedDefinitions unchecked(final Object target){ try{ return (UncheckedDefinitions) proxyClass.getConstructor(InvocationHandler.class).newInstance(new InvocationHandler(){ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (target instanceof Class){ return MethodUtils.invokeExactStaticMethod((Class) target, method.getName(), args); } return MethodUtils.invokeExactMethod(target, method.getName(), args); } }); } catch(Exception e){ throw new RuntimeException(e); } } } </code></pre> <p>And the usage looks like:</p> <pre><code>import static ....Unchecked.*; ... Writer w = ...; unchecked(w).write(str, off, len); </code></pre> <p>The trick is that interface is "never finished" and everytime I need unchecked method somewhere, I'll wrap that object into unchecked and let IDE generate method signature in interface.</p> <p>Implementation is then generic (reflective and "slow" but usually fast enough)</p> <p>There are some code post-processors and bytecode-weavers but this was not possible (not even aop or other jvm based language) for my current project, so this was "invented".</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload