New J2K: add multi-file conversion tests from old j2k
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package test;
|
||||
|
||||
public class Some {
|
||||
@SomeAnnotation(some = "Foo", same = 0)
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
|
||||
@SomeAnnotation(some = {"Bar", "Buz"}, same = {1, 2})
|
||||
public void bar() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
class Some {
|
||||
@SomeAnnotation(some = ["Foo"], same = [0])
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
@SomeAnnotation(some = ["Bar", "Buz"], same = [1, 2])
|
||||
fun bar() {
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface SomeAnnotation {
|
||||
String[] some() default {};
|
||||
int[] same() default {};
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface SomeAnnotation {
|
||||
String[] some() default {};
|
||||
int[] same() default {};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package test;
|
||||
|
||||
public class JavaClass {
|
||||
public int field = 0;
|
||||
|
||||
protected int myProperty = 0;
|
||||
|
||||
public int getProperty() {
|
||||
return myProperty;
|
||||
}
|
||||
|
||||
public static final String NAME = "Bar";
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
open class JavaClass {
|
||||
@JvmField
|
||||
var field = 0
|
||||
var property = 0
|
||||
protected set
|
||||
|
||||
companion object {
|
||||
const val NAME = "Bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package test;
|
||||
|
||||
public class C extends JavaClass {
|
||||
public void foo(JavaClass javaClass) {
|
||||
javaClass.field++;
|
||||
--javaClass.field;
|
||||
myProperty = javaClass.field;
|
||||
javaClass.field -= field;
|
||||
field = myProperty;
|
||||
field *= 2;
|
||||
field = field * 2;
|
||||
|
||||
String s = JavaClass.NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package test;
|
||||
|
||||
public class C extends JavaClass {
|
||||
public void foo(JavaClass javaClass) {
|
||||
javaClass.field++;
|
||||
--javaClass.field;
|
||||
property = javaClass.field;
|
||||
javaClass.field -= field;
|
||||
field = property;
|
||||
field *= 2;
|
||||
field = field * 2;
|
||||
|
||||
String s = JavaClass.NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
class C : JavaClass() {
|
||||
public fun foo(javaClass: JavaClass) {
|
||||
javaClass.field++
|
||||
myProperty = javaClass.field
|
||||
field = myProperty
|
||||
field *= 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
class C : JavaClass() {
|
||||
public fun foo(javaClass: JavaClass) {
|
||||
javaClass.field++
|
||||
property = javaClass.field
|
||||
field = property
|
||||
field *= 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package test;
|
||||
|
||||
public class Stage {
|
||||
public void context(Acceptor acceptor) {
|
||||
acceptor.acceptFace(new Face() {
|
||||
@Override
|
||||
public void subject(String p) {
|
||||
System.out.println(p);
|
||||
}
|
||||
});
|
||||
acceptor.setFace(new Face() {
|
||||
@Override
|
||||
public void subject(String p) {
|
||||
System.out.println(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test
|
||||
|
||||
class Stage {
|
||||
fun context(acceptor: Acceptor) {
|
||||
acceptor.acceptFace { p -> println(p) }
|
||||
acceptor.face = Face { p -> println(p) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package test;
|
||||
|
||||
public class Acceptor {
|
||||
private Face face;
|
||||
|
||||
public Face getFace() {
|
||||
return face;
|
||||
}
|
||||
|
||||
public void setFace(Face face) {
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
public void acceptFace(Face face) {
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test;
|
||||
|
||||
public class Acceptor {
|
||||
private Face face;
|
||||
|
||||
public Face getFace() {
|
||||
return face;
|
||||
}
|
||||
|
||||
public void setFace(Face face) {
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
public void acceptFace(Face face) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public interface Face {
|
||||
void subject(String p);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public interface Face {
|
||||
void subject(String p);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package test;
|
||||
|
||||
public class AAA {
|
||||
private int x = 42;
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
setX(getX() + 1);
|
||||
}
|
||||
|
||||
public void bar(B b) {
|
||||
System.out.println(b.getYY());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// ERROR: Unresolved reference: yy
|
||||
package test
|
||||
|
||||
class AAA {
|
||||
var x = 42
|
||||
|
||||
fun foo() {
|
||||
x = x + 1
|
||||
}
|
||||
|
||||
fun bar(b: B) {
|
||||
println(b.yy)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
public class B {
|
||||
void foo(AAA a) {
|
||||
a.setX(a.getX() + 1);
|
||||
y += "a";
|
||||
}
|
||||
|
||||
private String y = "";
|
||||
|
||||
public String getYY() {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
class B {
|
||||
fun foo(a: AAA) {
|
||||
a.x = a.x + 1
|
||||
yY += "a"
|
||||
}
|
||||
|
||||
var yY = ""
|
||||
private set
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import test.AAA
|
||||
|
||||
fun foo1(a: AAA) {
|
||||
a.setX(a.getX() + 1)
|
||||
}
|
||||
|
||||
fun foo2(a: AAA?) {
|
||||
a?.setX((a?.getX() ?: 0) + 1)
|
||||
}
|
||||
|
||||
fun AAA.foo() {
|
||||
setX(getX() + 1)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import test.AAA
|
||||
|
||||
fun foo1(a: AAA) {
|
||||
a.x = a.x + 1
|
||||
}
|
||||
|
||||
fun foo2(a: AAA?) {
|
||||
a?.x = (a?.x ?: 0) + 1
|
||||
}
|
||||
|
||||
fun AAA.foo() {
|
||||
x = x + 1
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
class JavaClass {
|
||||
void foo(AAA a) {
|
||||
a.setX(a.getX() + 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
class JavaClass {
|
||||
void foo(AAA a) {
|
||||
a.x = a.x + 1;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.Bar;
|
||||
|
||||
public class Foo {
|
||||
public static void foo() {
|
||||
Object o = Bar.SET;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.Bar
|
||||
|
||||
object Foo {
|
||||
fun foo() {
|
||||
val o: Any = Bar.SET
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Bar {
|
||||
Set<String> SET = new HashSet<String>() { };
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Bar {
|
||||
Set<String> SET = new HashSet<String>() { };
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
public class SomeServiceUsage {
|
||||
|
||||
public SomeService getService() {
|
||||
return SomeService.getInstanceNotNull();
|
||||
}
|
||||
|
||||
public SomeService getServiceNullable() {
|
||||
return SomeService.getInstanceNullable();
|
||||
}
|
||||
|
||||
// elvis
|
||||
public SomeService getServiceNotNullByDataFlow() {
|
||||
SomeService s = SomeService.getInstanceNullable();
|
||||
return s == null ? SomeService.getInstanceNotNull() : s;
|
||||
}
|
||||
|
||||
// nullable, bang-bang
|
||||
public String aString1() {
|
||||
return getServiceNullable().nullableString();
|
||||
}
|
||||
|
||||
// nullable
|
||||
public String aString2() {
|
||||
return getService().nullableString();
|
||||
}
|
||||
|
||||
// not nullable
|
||||
public String aString3() {
|
||||
return getService().notNullString();
|
||||
}
|
||||
|
||||
// nullable, no bang-bang
|
||||
public String aString4() {
|
||||
return getServiceNotNullByDataFlow().nullableString();
|
||||
}
|
||||
|
||||
// not nullable, no bang-bang
|
||||
public String aString5() {
|
||||
return getServiceNotNullByDataFlow().notNullString();
|
||||
}
|
||||
|
||||
// nullable, safe-call
|
||||
public String aString6() {
|
||||
SomeService s = getServiceNullable();
|
||||
if (s != null) {
|
||||
return s.nullableString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
class SomeServiceUsage {
|
||||
val service: SomeService
|
||||
get() = SomeService.getInstanceNotNull()
|
||||
|
||||
val serviceNullable: SomeService
|
||||
get() = SomeService.getInstanceNullable()
|
||||
|
||||
// elvis
|
||||
val serviceNotNullByDataFlow: SomeService
|
||||
get() {
|
||||
val s = SomeService.getInstanceNullable()
|
||||
return s ?: SomeService.getInstanceNotNull()
|
||||
}
|
||||
|
||||
// nullable, bang-bang
|
||||
fun aString1(): String {
|
||||
return serviceNullable.nullableString()
|
||||
}
|
||||
|
||||
// nullable
|
||||
fun aString2(): String {
|
||||
return service.nullableString()
|
||||
}
|
||||
|
||||
// not nullable
|
||||
fun aString3(): String {
|
||||
return service.notNullString()
|
||||
}
|
||||
|
||||
// nullable, no bang-bang
|
||||
fun aString4(): String {
|
||||
return serviceNotNullByDataFlow.nullableString()
|
||||
}
|
||||
|
||||
// not nullable, no bang-bang
|
||||
fun aString5(): String {
|
||||
return serviceNotNullByDataFlow.notNullString()
|
||||
}
|
||||
|
||||
// nullable, safe-call
|
||||
fun aString6(): String? {
|
||||
val s = serviceNullable
|
||||
return s?.nullableString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
public class SomeService {
|
||||
|
||||
public static SomeService getInstanceNotNull() {
|
||||
return new SomeService();
|
||||
}
|
||||
|
||||
public static SomeService getInstanceNullable() {
|
||||
if (Math.random() > 0.5)
|
||||
return null;
|
||||
return new SomeService();
|
||||
}
|
||||
|
||||
public String nullableString() {
|
||||
if (Math.random() < 0.5)
|
||||
return null;
|
||||
return Math.random() + "";
|
||||
}
|
||||
|
||||
public String notNullString() {
|
||||
String s = nullableString();
|
||||
if (s != null)
|
||||
return s;
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
public class SomeService {
|
||||
|
||||
public static SomeService getInstanceNotNull() {
|
||||
return new SomeService();
|
||||
}
|
||||
|
||||
public static SomeService getInstanceNullable() {
|
||||
if (Math.random() > 0.5)
|
||||
return null;
|
||||
return new SomeService();
|
||||
}
|
||||
|
||||
public String nullableString() {
|
||||
if (Math.random() < 0.5)
|
||||
return null;
|
||||
return Math.random() + "";
|
||||
}
|
||||
|
||||
public String notNullString() {
|
||||
String s = nullableString();
|
||||
if (s != null)
|
||||
return s;
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package test;
|
||||
|
||||
public class BaseOtherPackage {
|
||||
protected BaseOtherPackage() {
|
||||
|
||||
}
|
||||
|
||||
protected void foo() {
|
||||
|
||||
}
|
||||
|
||||
protected int i = 1;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
open class BaseOtherPackage protected constructor() {
|
||||
protected fun foo() {}
|
||||
protected var i = 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test2;
|
||||
|
||||
import test.*;
|
||||
|
||||
public class DerivedOtherPackage extends BaseOtherPackage {
|
||||
protected DerivedOtherPackage() {
|
||||
super();
|
||||
foo();
|
||||
int i = this.i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test2
|
||||
|
||||
import test.BaseOtherPackage
|
||||
|
||||
class DerivedOtherPackage protected constructor() : BaseOtherPackage() {
|
||||
init {
|
||||
foo()
|
||||
val i = i
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test3
|
||||
|
||||
import test.*
|
||||
|
||||
class DerivedOtherPackageKotlin : BaseOtherPackage() {
|
||||
init {
|
||||
foo()
|
||||
val i = this.i
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test3
|
||||
|
||||
import test.*
|
||||
|
||||
class DerivedOtherPackageKotlin : BaseOtherPackage() {
|
||||
init {
|
||||
foo()
|
||||
val i = this.i
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package test;
|
||||
|
||||
class ClassWithStatics {
|
||||
public void instanceMethod() {
|
||||
}
|
||||
|
||||
public static void staticMethod(int p) {
|
||||
}
|
||||
|
||||
public static final int staticField = 1;
|
||||
public static int staticNonFinalField = 1;
|
||||
|
||||
protected static int ourValue = 0;
|
||||
|
||||
public static int getValue() {
|
||||
return ourValue;
|
||||
}
|
||||
|
||||
public static void setValue(int value) {
|
||||
ourValue = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package test
|
||||
|
||||
internal open class ClassWithStatics {
|
||||
fun instanceMethod() {}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun staticMethod(p: Int) {}
|
||||
const val staticField = 1
|
||||
@JvmField
|
||||
var staticNonFinalField = 1
|
||||
var value = 0
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package test;
|
||||
|
||||
class C {
|
||||
void foo(ClassWithStatics c) {
|
||||
ClassWithStatics.staticMethod(ClassWithStatics.staticField);
|
||||
c.instanceMethod();
|
||||
ClassWithStatics.staticNonFinalField += 2;
|
||||
}
|
||||
|
||||
void methodReferences() {
|
||||
Object staticMethod = ClassWithStatics::staticMethod;
|
||||
Object instanceMethod = ClassWithStatics::instanceMethod;
|
||||
}
|
||||
}
|
||||
|
||||
class D extends ClassWithStatics {
|
||||
void foo() {
|
||||
staticMethod(staticField);
|
||||
ourValue *= 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package test;
|
||||
|
||||
class C {
|
||||
void foo(ClassWithStatics c) {
|
||||
ClassWithStatics.staticMethod(ClassWithStatics.staticField);
|
||||
c.instanceMethod();
|
||||
ClassWithStatics.staticNonFinalField += 2;
|
||||
}
|
||||
|
||||
void methodReferences() {
|
||||
Object staticMethod = ClassWithStatics::staticMethod;
|
||||
Object instanceMethod = ClassWithStatics::instanceMethod;
|
||||
}
|
||||
}
|
||||
|
||||
class D extends ClassWithStatics {
|
||||
void foo() {
|
||||
staticMethod(staticField);
|
||||
value *= 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
fun foo() {
|
||||
ClassWithStatics.staticMethod(ClassWithStatics.staticField)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
fun foo() {
|
||||
ClassWithStatics.staticMethod(ClassWithStatics.staticField)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package test;
|
||||
|
||||
public class PureUtils {
|
||||
public static void foo1(int p) {}
|
||||
public static int foo2() { return 1; }
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
object PureUtils {
|
||||
@JvmStatic
|
||||
fun foo1(p: Int) {}
|
||||
@JvmStatic
|
||||
fun foo2(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package test;
|
||||
|
||||
public class Utils {
|
||||
public static void foo1(int p) {
|
||||
}
|
||||
|
||||
public static int foo2() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int staticField = 1;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package test
|
||||
|
||||
object Utils {
|
||||
@JvmStatic
|
||||
fun foo1(p: Int) {}
|
||||
@JvmStatic
|
||||
fun foo2(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
@JvmField
|
||||
var staticField = 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
|
||||
|
||||
class C {
|
||||
void foo() {
|
||||
Utils.foo1(Utils.staticField);
|
||||
Utils.staticField += Utils.foo2();
|
||||
PureUtils.foo1(PureUtils.foo2());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
|
||||
|
||||
class C {
|
||||
void foo() {
|
||||
Utils.foo1(Utils.staticField);
|
||||
Utils.staticField += Utils.foo2();
|
||||
PureUtils.foo1(PureUtils.foo2());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
fun foo() {
|
||||
Utils.foo1(Utils.staticField)
|
||||
PureUtils.foo1(PureUtils.foo2())
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
fun foo() {
|
||||
Utils.foo1(Utils.staticField)
|
||||
PureUtils.foo1(PureUtils.foo2())
|
||||
}
|
||||
Reference in New Issue
Block a user