UnsupportedOperationException - need better error message

35 views
Skip to first unread message

Patrick Wright

unread,
Mar 14, 2012, 6:28:00 AM3/14/12
to jewelcli
First, I've been a happy user of JewelCLI for some time now and
recommend it to everyone I work with. Great job!

I have a problem that appears to have come along in moving between the
old package 0.58 to the new one, 0.8.1. The issue is that in the old
version, an Option which did not follow the JavaBeans naming
convention for getters was processed, while in the new one it is
ignored and an exception will be thrown when one tries to use it.

Example: I have a simple interface
public interface Options {
@Option String name();
}

The I parse the args
options = CliFactory.parseArguments(Options.class, args);
System.out.println("name: " + options.name())

I will get an exception
Exception in thread "main" java.lang.UnsupportedOperationException: no
implemention found for method public abstract java.lang.String
com.test.Main$Options.name()
at com.lexicalscope.jewelcli.internal.fluentreflection.dynamicproxy.
$Implementing.invoke(Implementing.java:165)
at $Proxy4.name(Unknown Source)

I understand why this happens, but perhaps there could be an exception
thrown during parsing? For example, if a method marked @Option does
not follow the JavaBeans naming convention, throw an exception.

This has bitten me a couple of times in the last few months as I am
still using the 0.58 on some old projects. The exception message is
not helpful - I thought there was a problem with a proxying library or
dependency conflict.

Thanks!
Patrick

Tim Wood

unread,
Mar 14, 2012, 8:17:06 AM3/14/12
to jewe...@googlegroups.com
Hi,

Thanks. I have added this as an issue on github.

https://github.com/lexicalscope/jewelcli/issues/14

I probably won't get time to look at a fix for it this week, but I'll
try to look at how to improve it some time next week.

I wonder if the best thing would be to add support for the "name()"
convention as well as the "getName()" convention? Or throw an more
helpful exception during parsing?

Cheers,

Tim

Patrick Wright

unread,
Mar 14, 2012, 10:52:35 AM3/14/12
to jewe...@googlegroups.com
Hi Tim

no hurry on the fix, I understand the issue and can work with the
current approach.

Personally, I don't see a reason to require the JB spec here - I like
using name() because that's what the command-line arg looks like
anyway "--name=XXXX".


Cheers
Patrick

Tim Wood

unread,
Apr 11, 2012, 5:30:10 PM4/11/12
to jewe...@googlegroups.com
This is fixed in release 0.8.2. Both getName() and name() will work again.

Blog article with examples:
http://www.lexicalscope.com/blog/2012/04/11/jewelcli-accessor-method-names/

Download:
http://repo1.maven.org/maven2/com/lexicalscope/jewelcli/jewelcli/0.8.2/

Patrick Wright

unread,
Apr 12, 2012, 2:12:12 AM4/12/12
to jewe...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages