# Java Interface/Implementation Model

**URL:** <https://community.temporal.io/t/java-interface-implementation-model/523>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [August 24, 2020, 5:51pm UTC](https://community.temporal.io/t/java-interface-implementation-model/523 "2020-08-24T17:51:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordon\_Bean](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/gordon_bean/32/224_2.png) [@Gordon\_Bean](https://community.temporal.io/u/Gordon_Bean)\
**Post date:** [August 24, 2020, 5:51pm UTC](https://community.temporal.io/t/java-interface-implementation-model/523/1 "2020-08-24T17:51:09Z")

</div>

In Java, all methods are virtual. This allows frameworks like Mockito to create unit-testing stubs from any class: `MyFoo foo = Mockito.mock(MyFoo.class);`

Temporal, however, requires that I declare an interface and an implementation for my activities and workflows.

Is this a hard requirement, or just an implementation detail? Could the Temporal java-sdk be written in a way as to require only annotating the implementation class/methods with `@TemporalWorkfow`, `@WorkflowMethod`, `@QueryMethod`, etc?

The same idea applies to python as well, which has even less of a concept of interfaces.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 24, 2020, 6:47pm UTC](https://community.temporal.io/t/java-interface-implementation-model/523/3 "2020-08-24T18:47:38Z")

</div>

I cannot comment on Python as I never wrote a line of production code in it.

Invocation of workflows and activities are essentially remote calls. So the framework needs a way to define APIs of workflows and activities in a clear way. Java interfaces were chosen for this specification.

Also I learned a hard way that forcing any framework that relies on dynamic code or bytecode manipulation on the users is not a good idea.
