Skip to content

JavaReflectionImposteriser and Scala #74

Open
@nargov

Description

@nargov

Hi,

I've been writing a small integration library between JMock and specs2, since we love JMock here at Wix, but we write mostly in Scala now.
I encountered an issue where the JavaReflectionImposteriser would fail to create a mock from a Scala trait that contains a function that returns a Scala Set.
It fails because the Imposteriser uses JDKs Proxy which is unable to create the instance. This is due to Set having two apply methods:

apply(T): Boolean

and

apply(T*:): CC[T]

Since Java ignores Scala's way of creating parameter lists, it things both methods have the same signature but with different return types.

I have worked around this by creating a new Imposteriser, which uses the JavaReflectionImposteriser, and if it fails because of that error, uses the ClassImposteriser instead.

I just thought you guys might find this interesting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions