Skip to content

Commit 7120676

Browse files
committed
test/fix overloaded synchronized methods
1 parent 39d019a commit 7120676

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

java2python/config/default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@
9797
methodPrologueHandlers = [
9898
basic.maybeAbstractMethod,
9999
basic.maybeClassMethod,
100+
basic.overloadedClassMethods,
100101
# NB: synchronized should come after classmethod
101102
basic.maybeSynchronizedMethod,
102-
basic.overloadedClassMethods,
103103
]
104104

105105

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class classmethod_(classmethod):
2+
""" Classmethod that provides attribute delegation.
3+
4+
"""
5+
def __getattr__(self, name):
6+
return getattr(self.__func__, name)

test/Synchronized2.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class Synchronized2 {
2+
3+
public synchronized void test1() {
4+
System.out.println(1);
5+
}
6+
7+
public synchronized void test1(String s) {
8+
System.out.println(s);
9+
}
10+
11+
public static synchronized void test1(int i) {
12+
System.out.println(i);
13+
}
14+
15+
public static synchronized void test2() {
16+
System.out.println(2);
17+
}
18+
19+
public static synchronized void test2(String s) {
20+
System.out.println(s);
21+
}
22+
23+
public synchronized void test2(int i) {
24+
System.out.println(i);
25+
}
26+
27+
public static void main(String[] args) {
28+
Synchronized2 obj = new Synchronized2();
29+
obj.test1();
30+
obj.test1("test1");
31+
obj.test1(1);
32+
obj.test2();
33+
obj.test2("test2");
34+
obj.test2(2);
35+
}
36+
}

test/configs/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
modulePrologueHandlers = default.modulePrologueHandlers + [
7+
'from java2python.mod.include.classmethod import classmethod_ as classmethod',
78
'from java2python.mod.include.overloading import overloaded',
89
'from abc import ABCMeta, abstractmethod',
910
'import zope.interface',

0 commit comments

Comments
 (0)