On Fri, 17 Aug 2012, csrickle wrote:
...
This is an Apache Accumulo interface. The particular class containing the
nested class, analogous to App.Embedded.hello2(), is
TabletServerBatchReaderIterator:
http://svn.apache.org/viewvc/accumulo/tags/1.4.1/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java?view=markup
Getting jcc to recognize MyEntry (listed below) is the actual problem I'm
still hoping to solve.
private static class MyEntry implements Entry<Key,Value> {
98
99 private Key key;
100 private Value value;
101
102 MyEntry(Key key, Value value) {
103 this.key = key;
104 this.value = value;
105 }
106
107 @Override
108 public Key getKey() {
109 return key;
110 }
111
112 @Override
113 public Value getValue() {
114 return value;
115 }
116
117 @Override
118 public Value setValue(Value value) {
119 throw new UnsupportedOperationException();
120 }
121
122 }
If this class is contained within a specified --jar argument in the jcc
invocation, can I then add a --rename command such that I can refer to the
"private" and "static" MyEntry class.
When using --jar, only public classes are wrapped. The reason is that
non-public classes are not meant to be accessed from the outside and that
this offers a great way to reduce the amount of code generated by JCC.
This is also why you should carefully consider which --package flags to use
so that dependencies to classes outside the set you'd like to wrap also get
wrapped. By default, methods whose signature refers to classes outside your
wrap-set that are not in a package listed with --package are skipped.
If JCC was greedy in its wrapping by default, you'd very quickly end up
wrapping the entire JRE.
Now, to your question more specifically: to wrap a non-public class, just
list their name on the jcc command line.
For example, if you change your jcchello Embedded class to private and give
it a public constructor, then your earlier example still works as before,
you can still call AppEmbedded(App()).hello2(). If you don't give it a
public constructor, you won't be able to instantiate Embedded from the
outside, as only public methods and constructors are wrapped, for similar
reasons.
Andi..