3

In java, my code looks like:

new Injector(ClassToInjectOn.class, whatever)

so, the Injector class wants some Class<> argument. Works fine when doing things in Java.

But now I want to configure an injector object using jython.

I tried:

Injector(ClassToInjectOn.class, whatever) 

results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: instance attr: class

I tried auto-completion; and found that I could use ClassToInjectOn.__class__ ... but then the Class object that is passed into the injector will be java.lang.Class (but should be ClassToInjectOn.class).

Unfortunately searching for python and ".class" doesn't really provide useful answers.

1 Answer 1

4

In python ClassToInjectOn is the class object. This is why ClassToInjectOn.__class__ gives you java.lang.Class, because that's what the class of a class object. So you need only write:

Injector(ClassToInjectOn, whatever) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.