From: Lew on
Krishna K wrote:
> Thanks for the reply, they are not in the same package, 'B' wouldn't
> know the package name of 'A', thus it wouldn't know the type of 'that
> Class', the point is for 'A' to pass that information so the module in
> 'B' can us e that information.- Hide quoted text -
>

Sounds like a bad design is operating here.

See the advice elsethread to supply an SSCCE.

The method in 'B' should have an argument that specifies the expected
type. The nested class of 'A' should inherit that type. Perhaps
generics would help.

public class A
{
public static class Foo implements Usable
{
@Override // override Usable#whatever()
public Bar whatever()
{
Bar retval = obtainBar(); // your logic here
return retval;
}
}
public void doSomething()
{
B helper = new B();
Foo foo = new Foo();
helper.helpMe( foo );
// ... etc.
}
}

public class B
{
public void helpMe( Usable foo )
{
// ... etc.
}
}

Forget reflection and use of Class<T> if you can help it.

--
Lew
From: Robert Klemme on
On 16.06.2010 13:24, Lew wrote:
> On 06/16/2010 02:30 AM, Krishna K wrote:
>> Passing a class to the library being used
>> 'A' is a java application (package) which uses library 'B', when
>> calling a particular method of a module in 'B' a class in 'A' needs to
>> be passed, this class has some static inner classs that the callee in
>
> By definition, an inner class is not static. See the Java Language
> Specification (JLS). Did you mean "static nested class"?

Just for the reference of terms "inner class" and "nested class":

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
From: John B. Matthews on
In article <87ttp7Fv7aU2(a)mid.individual.net>,
Robert Klemme <shortcutter(a)googlemail.com> wrote:

> On 16.06.2010 13:24, Lew wrote:
> > On 06/16/2010 02:30 AM, Krishna K wrote:
> >> Passing a class to the library being used
> >> 'A' is a java application (package) which uses library 'B', when
> >> calling a particular method of a module in 'B' a class in 'A' needs to
> >> be passed, this class has some static inner classs that the callee in
> >
> > By definition, an inner class is not static. See the Java Language
> > Specification (JLS). Did you mean "static nested class"?
>
> Just for the reference of terms "inner class" and "nested class":
>
> http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3

In addition, I often (have to) refer to this tutorial:

<http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html>

And picture:

<http://blogs.sun.com/darcy/entry/nested_inner_member_and_top>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
First  |  Prev  | 
Pages: 1 2
Prev: Hashtable updates to disk
Next: Changing coordinates