Menu

#10 preserve method parameter names

open
nobody
None
5
2002-04-24
2002-04-24
No

The generated mock class doesn't seem to preserve the
method names specified in the interface for which the
class was generated.

Example: Let's say I want to generate a mock
implementation for the interface Foo defined as
follows:

public interface Foo {
setBar(Object bar);
}

The generated mock implementation class MockFoo will
have the method defined as follows:

setBar(Object arg0) {
...
}

I think it would be nice if the argument names were
preserved, as it is easier to understand the code when
reading it. Sometimes you want to make adaptions to
the generated code.

Discussion

  • Matthew Cooke

    Matthew Cooke - 2002-05-20

    Logged In: YES
    user_id=136463

    I'm not sure how easy this is to do at the moment. Mockmaker
    works on the compiled bytecode files and I don't think these
    files keep the parameter names. To do this I think we would
    need to be generating mocks from source files.

     
  • Knut Wannheden

    Knut Wannheden - 2002-05-21

    Logged In: YES
    user_id=455308

    Although I think the method parameter names are stored in
    the bytecode files, the java.lang.reflect package does
    unfortunately not provide access to them. Other packages
    such as BCEL (http://jakarta.pache.org/bcel/) provide this
    access. They would also allow to write the mock classes to
    bytecode directly, instead of Java source. But that's of
    course not always desirable...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.