Permalink
Browse files

Allow @OnVersionChange methods without version number parameters.

  • Loading branch information...
archiecobbs committed Nov 22, 2018
1 parent bc3cec0 commit a72629141ddd0c6c74451fdc3f821b9ca897d4e7
@@ -1,6 +1,7 @@
Version Next
- Fixed infinite loop when parsing certain invalid cast expressions
- Allow @OnVersionChange methods without version number parameters
Version 4.1.2 Released October 26, 2018
2 TODO
@@ -19,8 +19,6 @@ SHORT TERM
- ByteBuffer cleanup for ArrayKVStore ?
https://github.com/dain/leveldb/blob/master/leveldb/src/main/java/org/iq80/leveldb/util/ByteBufferSupport.java
- Support @OnVersionChange without version number parameters
- Only do extra DB sanity checks during the first transaction
- Connection pooling in SQL k/v implementations
@@ -44,11 +44,15 @@ protected boolean includeMethod(Method method, OnVersionChange annotation) {
this.checkNotStatic(method);
this.checkReturnType(method, void.class);
final int numParams = method.getParameterTypes().length;
// Handle @OnVersionChange version numbers; allow both to be omitted
int index = 0;
if (annotation.oldVersion() == 0)
this.checkParameterType(method, index++, TypeToken.of(int.class));
if (annotation.newVersion() == 0)
this.checkParameterType(method, index++, TypeToken.of(int.class));
if (!(annotation.oldVersion() == 0 && annotation.newVersion() == 0 && numParams == 1)) {
if (annotation.oldVersion() == 0)
this.checkParameterType(method, index++, TypeToken.of(int.class));
if (annotation.newVersion() == 0)
this.checkParameterType(method, index++, TypeToken.of(int.class));
}
final ArrayList<TypeToken<?>> choices = new ArrayList<TypeToken<?>>(2);
choices.add(this.byStorageIdType);
choices.add(this.byNameType);
@@ -252,6 +252,11 @@ public void testSignature1() throws Exception {
}
}
@Test
public void testSignature2() throws Exception {
BasicTest.getPermazen(SignatureCheck2.class);
}
// HasName
public interface HasName {
@@ -468,4 +473,12 @@ private void versionChange(int oldVersion, Map<Integer, Object> oldValues) {
private void migrate(int oldVersion, int newVersion, Map<Integer, Object> oldValues, float bogus) {
}
}
@PermazenType
public abstract static class SignatureCheck2 implements JObject {
@OnVersionChange
private void migrate(Map<Integer, Object> oldValues) {
}
}
}

0 comments on commit a726291

Please sign in to comment.