google / google/j2objc

Using mockito to mock interface with @ObjectiveCName results in failure

Open
#904 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6k
Forks
999
Avg merge
19h 20m
Merged PRs (30d)
14

Description

This used to work in 2.0.0, but broke sometime between then in 2.0.4

if one has something like

```java
@ObjectiveCName("OMGFoo")
public interface Foo {
void doSomething();
}
```

and then
```java
org.mockito.Mockito.mock(Foo.class)
```

it will blow up with

```
4) throwsOnServerError(omg.bbq.FooTest)
java.lang.IllegalArgumentException: interface omg.bbq.Foo is not visible from class loader
at 0x0000000107090fb8 java.lang.reflect.Proxy.getProxyClass0() + 1777
at 0x0000000107091156 java.lang.reflect.Proxy.newProxyInstance() + 45
at 0x000000010750181d org.mockito.internal.util.MockUtil.createMock() + 65
at 0x00000001074e22ad org.mockito.internal.MockitoCore.mock() + 131
at 0x0000000106dc9590 com.squareup.shared.catalog.sync.WriteMessageTest.setup() + 144
at 0x00000001072e80cd java.lang.reflect.Method.invoke:object:() + 22
```

Observed this in 2.0.4 and 2.0.5.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.