Skip to content

Instantly share code, notes, and snippets.

View odrotbohm's full-sized avatar
👨‍💻
@ home

Oliver Drotbohm odrotbohm

👨‍💻
@ home
View GitHub Profile

Hibernate Enhancer problem on Java 11

Spring RESTBucks uses Hibernate’s bytecode enhancement to avoid runtime overhead in favor of a build time step. This works fine on JDK 8. However, if the project is built on JDK 11, starting it fails with:

Caused by: java.lang.IllegalAccessError: Update to non-static final field org.springsource.restbucks.payment.Payment.order attempted from a different method ($$_hibernate_write_order) than the initializer method <init>
	at org.springsource.restbucks.payment.Payment.$$_hibernate_write_order(Payment.java) ~[classes/:na]
@odrotbohm
odrotbohm / readme.adoc
Created July 1, 2019 09:57
Proposal – Leveraging hypermedia in Android clients

Hypermedia in Android clients

Context

When it comes to JVM based clients of REST / HTTP APIs, Android is the most dominant platform. There are a variety of HTTP client libraries available for Android, but none of them have dedicated support to work with hypermedia elements (like links and forms) or late binding of data. Using those elements is crucial to avoid strong coupling between client and server. See this presentation (slides, recording for details.

Idea

Wanted but not invoked:
entityLinks.linkForItemResource(
class org.springframework.data.rest.core.domain.Profile,
isNull()
);
-> at org.springframework.data.rest.core.support.DefaultSelfLinkProviderUnitTests.looksUpSelfLinksForProxies(DefaultSelfLinkProviderUnitTests.java:144)
However, there was exactly 1 interaction with this mock:
entityLinks.linkToItemResource(
class org.springframework.data.rest.core.domain.Profile,
class Sample {
public this someMethod() {
// …
return this;
}
}
class Subtype extends Sample {};

Keybase proof

I hereby claim:

  • I am odrotbohm on github.
  • I am odrotbohm (https://keybase.io/odrotbohm) on keybase.
  • I have a public key ASBAoaL1ovuekChAwlljeBmx1owaUCg5zwckYgcSGiGeAQo

To claim this, I am signing this object:

@odrotbohm
odrotbohm / after.json
Last active September 4, 2018 08:59
Improved projection links with Spring Data REST
{
"_embedded" : {
"orders" : [ {
"items" : [ {
"description" : "Lakewood guitar",
"price" : 1299.00
} ],
"_embedded" : {
"customer" : {
"address" : "4711 Some Place, 54321 Charlottesville, VA",
@odrotbohm
odrotbohm / gist:3141439
Created July 19, 2012 07:49
Proposal: Allow EntityManager(Factory) to be injected through a constructor.

When designing application components it's best practice to inject mandatory dependencies though the constructor and essentially make the application component immutable like this:

@Named
class MyComponent implements Component {

  private final Dependency dependency;

  @Inject
 public MyComponent(Dependency dependency) {
@Component
public class MockPostProcessor implements BeanPostProcessor {
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
public class Sample {
public static void main(String[] args) {
Foo<? extends Bar<?>> foo = new Foo<>();
// Compiles
Iterable<?> first = foo.someMethod();
DedicatedWrapper<? extends Bar<?>> dedicatedWrapper = foo.someOtherMethod();
@MappedSuperclass
public abstract class AbstractAuditable<U, PK extends Serializable> extends AbstractPersistable<PK> implements
Auditable<U, PK> {
// …
}