1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package com.sun.star.lib.uno.bridges.javaremote;
25 
26 import com.sun.star.bridge.XInstanceProvider;
27 import com.sun.star.lib.TestBed;
28 import com.sun.star.lib.uno.typeinfo.MethodTypeInfo;
29 import com.sun.star.lib.uno.typeinfo.TypeInfo;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XComponentContext;
32 import com.sun.star.uno.XInterface;
33 import complexlib.ComplexTestCase;
34 
35 /**
36  * Test case for bug #111153#.
37  *
38  * <P>Bug #111153# "jni_uno bridge sometimes fails to map objects
39  * correctly" describes that mapping a local object out with type XDerived and
40  * then mapping it back in with type XBase produces a proxy, instead of
41  * short-cutting to the local object.</P>
42  */
43 public final class MethodIdTest extends ComplexTestCase {
getTestMethodNames()44     public String[] getTestMethodNames() {
45         return new String[] { "test" };
46     }
47 
test()48     public void test() throws Exception {
49         assure(
50             "test",
51             new TestBed().execute(new Provider(), false, Client.class, 0));
52     }
53 
54     public static final class Client extends TestBed.Client {
main(String[] args)55         public static void main(String[] args) {
56             new Client().execute();
57         }
58 
run(XComponentContext context)59         protected boolean run(XComponentContext context) throws Throwable {
60             XTest t = UnoRuntime.queryInterface(
61                 XTest.class, getBridge(context).getInstance("Test"));
62             return t.f129() == 129;
63         }
64     }
65 
66     private static final class Provider implements XInstanceProvider {
getInstance(String instanceName)67         public Object getInstance(String instanceName) {
68             return new XTest() {
69                     public int f0() { return 0; }
70                     public int f1() { return 1; }
71                     public int f2() { return 2; }
72                     public int f3() { return 3; }
73                     public int f4() { return 4; }
74                     public int f5() { return 5; }
75                     public int f6() { return 6; }
76                     public int f7() { return 7; }
77                     public int f8() { return 8; }
78                     public int f9() { return 9; }
79                     public int f10() { return 10; }
80                     public int f11() { return 11; }
81                     public int f12() { return 12; }
82                     public int f13() { return 13; }
83                     public int f14() { return 14; }
84                     public int f15() { return 15; }
85                     public int f16() { return 16; }
86                     public int f17() { return 17; }
87                     public int f18() { return 18; }
88                     public int f19() { return 19; }
89                     public int f20() { return 20; }
90                     public int f21() { return 21; }
91                     public int f22() { return 22; }
92                     public int f23() { return 23; }
93                     public int f24() { return 24; }
94                     public int f25() { return 25; }
95                     public int f26() { return 26; }
96                     public int f27() { return 27; }
97                     public int f28() { return 28; }
98                     public int f29() { return 29; }
99                     public int f30() { return 30; }
100                     public int f31() { return 31; }
101                     public int f32() { return 32; }
102                     public int f33() { return 33; }
103                     public int f34() { return 34; }
104                     public int f35() { return 35; }
105                     public int f36() { return 36; }
106                     public int f37() { return 37; }
107                     public int f38() { return 38; }
108                     public int f39() { return 39; }
109                     public int f40() { return 40; }
110                     public int f41() { return 41; }
111                     public int f42() { return 42; }
112                     public int f43() { return 43; }
113                     public int f44() { return 44; }
114                     public int f45() { return 45; }
115                     public int f46() { return 46; }
116                     public int f47() { return 47; }
117                     public int f48() { return 48; }
118                     public int f49() { return 49; }
119                     public int f50() { return 50; }
120                     public int f51() { return 51; }
121                     public int f52() { return 52; }
122                     public int f53() { return 53; }
123                     public int f54() { return 54; }
124                     public int f55() { return 55; }
125                     public int f56() { return 56; }
126                     public int f57() { return 57; }
127                     public int f58() { return 58; }
128                     public int f59() { return 59; }
129                     public int f60() { return 60; }
130                     public int f61() { return 61; }
131                     public int f62() { return 62; }
132                     public int f63() { return 63; }
133                     public int f64() { return 64; }
134                     public int f65() { return 65; }
135                     public int f66() { return 66; }
136                     public int f67() { return 67; }
137                     public int f68() { return 68; }
138                     public int f69() { return 69; }
139                     public int f70() { return 70; }
140                     public int f71() { return 71; }
141                     public int f72() { return 72; }
142                     public int f73() { return 73; }
143                     public int f74() { return 74; }
144                     public int f75() { return 75; }
145                     public int f76() { return 76; }
146                     public int f77() { return 77; }
147                     public int f78() { return 78; }
148                     public int f79() { return 79; }
149                     public int f80() { return 80; }
150                     public int f81() { return 81; }
151                     public int f82() { return 82; }
152                     public int f83() { return 83; }
153                     public int f84() { return 84; }
154                     public int f85() { return 85; }
155                     public int f86() { return 86; }
156                     public int f87() { return 87; }
157                     public int f88() { return 88; }
158                     public int f89() { return 89; }
159                     public int f90() { return 90; }
160                     public int f91() { return 91; }
161                     public int f92() { return 92; }
162                     public int f93() { return 93; }
163                     public int f94() { return 94; }
164                     public int f95() { return 95; }
165                     public int f96() { return 96; }
166                     public int f97() { return 97; }
167                     public int f98() { return 98; }
168                     public int f99() { return 99; }
169                     public int f100() { return 100; }
170                     public int f101() { return 101; }
171                     public int f102() { return 102; }
172                     public int f103() { return 103; }
173                     public int f104() { return 104; }
174                     public int f105() { return 105; }
175                     public int f106() { return 106; }
176                     public int f107() { return 107; }
177                     public int f108() { return 108; }
178                     public int f109() { return 109; }
179                     public int f110() { return 110; }
180                     public int f111() { return 111; }
181                     public int f112() { return 112; }
182                     public int f113() { return 113; }
183                     public int f114() { return 114; }
184                     public int f115() { return 115; }
185                     public int f116() { return 116; }
186                     public int f117() { return 117; }
187                     public int f118() { return 118; }
188                     public int f119() { return 119; }
189                     public int f120() { return 120; }
190                     public int f121() { return 121; }
191                     public int f122() { return 122; }
192                     public int f123() { return 123; }
193                     public int f124() { return 124; }
194                     public int f125() { return 125; }
195                     public int f126() { return 126; }
196                     public int f127() { return 127; }
197                     public int f128() { return 128; }
198                     public int f129() { return 129; }
199                     public int f130() { return 130; }
200                 };
201         }
202     }
203 
204     public interface XTest extends XInterface {
205         int f0();
206         int f1();
207         int f2();
208         int f3();
209         int f4();
210         int f5();
211         int f6();
212         int f7();
213         int f8();
214         int f9();
215         int f10();
216         int f11();
217         int f12();
218         int f13();
219         int f14();
220         int f15();
221         int f16();
222         int f17();
223         int f18();
224         int f19();
225         int f20();
226         int f21();
227         int f22();
228         int f23();
229         int f24();
230         int f25();
231         int f26();
232         int f27();
233         int f28();
234         int f29();
235         int f30();
236         int f31();
237         int f32();
238         int f33();
239         int f34();
240         int f35();
241         int f36();
242         int f37();
243         int f38();
244         int f39();
245         int f40();
246         int f41();
247         int f42();
248         int f43();
249         int f44();
250         int f45();
251         int f46();
252         int f47();
253         int f48();
254         int f49();
255         int f50();
256         int f51();
257         int f52();
258         int f53();
259         int f54();
260         int f55();
261         int f56();
262         int f57();
263         int f58();
264         int f59();
265         int f60();
266         int f61();
267         int f62();
268         int f63();
269         int f64();
270         int f65();
271         int f66();
272         int f67();
273         int f68();
274         int f69();
275         int f70();
276         int f71();
277         int f72();
278         int f73();
279         int f74();
280         int f75();
281         int f76();
282         int f77();
283         int f78();
284         int f79();
285         int f80();
286         int f81();
287         int f82();
288         int f83();
289         int f84();
290         int f85();
291         int f86();
292         int f87();
293         int f88();
294         int f89();
295         int f90();
296         int f91();
297         int f92();
298         int f93();
299         int f94();
300         int f95();
301         int f96();
302         int f97();
303         int f98();
304         int f99();
305         int f100();
306         int f101();
307         int f102();
308         int f103();
309         int f104();
310         int f105();
311         int f106();
312         int f107();
313         int f108();
314         int f109();
315         int f110();
316         int f111();
317         int f112();
318         int f113();
319         int f114();
320         int f115();
321         int f116();
322         int f117();
323         int f118();
324         int f119();
325         int f120();
326         int f121();
327         int f122();
328         int f123();
329         int f124();
330         int f125();
331         int f126();
332         int f127();
333         int f128();
334         int f129();
335         int f130();
336 
337         TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("f0", 0, 0),
338                                    new MethodTypeInfo("f1", 1, 0),
339                                    new MethodTypeInfo("f2", 2, 0),
340                                    new MethodTypeInfo("f3", 3, 0),
341                                    new MethodTypeInfo("f4", 4, 0),
342                                    new MethodTypeInfo("f5", 5, 0),
343                                    new MethodTypeInfo("f6", 6, 0),
344                                    new MethodTypeInfo("f7", 7, 0),
345                                    new MethodTypeInfo("f8", 8, 0),
346                                    new MethodTypeInfo("f9", 9, 0),
347                                    new MethodTypeInfo("f10", 10, 0),
348                                    new MethodTypeInfo("f11", 11, 0),
349                                    new MethodTypeInfo("f12", 12, 0),
350                                    new MethodTypeInfo("f13", 13, 0),
351                                    new MethodTypeInfo("f14", 14, 0),
352                                    new MethodTypeInfo("f15", 15, 0),
353                                    new MethodTypeInfo("f16", 16, 0),
354                                    new MethodTypeInfo("f17", 17, 0),
355                                    new MethodTypeInfo("f18", 18, 0),
356                                    new MethodTypeInfo("f19", 19, 0),
357                                    new MethodTypeInfo("f20", 20, 0),
358                                    new MethodTypeInfo("f21", 21, 0),
359                                    new MethodTypeInfo("f22", 22, 0),
360                                    new MethodTypeInfo("f23", 23, 0),
361                                    new MethodTypeInfo("f24", 24, 0),
362                                    new MethodTypeInfo("f25", 25, 0),
363                                    new MethodTypeInfo("f26", 26, 0),
364                                    new MethodTypeInfo("f27", 27, 0),
365                                    new MethodTypeInfo("f28", 28, 0),
366                                    new MethodTypeInfo("f29", 29, 0),
367                                    new MethodTypeInfo("f30", 30, 0),
368                                    new MethodTypeInfo("f31", 31, 0),
369                                    new MethodTypeInfo("f32", 32, 0),
370                                    new MethodTypeInfo("f33", 33, 0),
371                                    new MethodTypeInfo("f34", 34, 0),
372                                    new MethodTypeInfo("f35", 35, 0),
373                                    new MethodTypeInfo("f36", 36, 0),
374                                    new MethodTypeInfo("f37", 37, 0),
375                                    new MethodTypeInfo("f38", 38, 0),
376                                    new MethodTypeInfo("f39", 39, 0),
377                                    new MethodTypeInfo("f40", 40, 0),
378                                    new MethodTypeInfo("f41", 41, 0),
379                                    new MethodTypeInfo("f42", 42, 0),
380                                    new MethodTypeInfo("f43", 43, 0),
381                                    new MethodTypeInfo("f44", 44, 0),
382                                    new MethodTypeInfo("f45", 45, 0),
383                                    new MethodTypeInfo("f46", 46, 0),
384                                    new MethodTypeInfo("f47", 47, 0),
385                                    new MethodTypeInfo("f48", 48, 0),
386                                    new MethodTypeInfo("f49", 49, 0),
387                                    new MethodTypeInfo("f50", 50, 0),
388                                    new MethodTypeInfo("f51", 51, 0),
389                                    new MethodTypeInfo("f52", 52, 0),
390                                    new MethodTypeInfo("f53", 53, 0),
391                                    new MethodTypeInfo("f54", 54, 0),
392                                    new MethodTypeInfo("f55", 55, 0),
393                                    new MethodTypeInfo("f56", 56, 0),
394                                    new MethodTypeInfo("f57", 57, 0),
395                                    new MethodTypeInfo("f58", 58, 0),
396                                    new MethodTypeInfo("f59", 59, 0),
397                                    new MethodTypeInfo("f60", 60, 0),
398                                    new MethodTypeInfo("f61", 61, 0),
399                                    new MethodTypeInfo("f62", 62, 0),
400                                    new MethodTypeInfo("f63", 63, 0),
401                                    new MethodTypeInfo("f64", 64, 0),
402                                    new MethodTypeInfo("f65", 65, 0),
403                                    new MethodTypeInfo("f66", 66, 0),
404                                    new MethodTypeInfo("f67", 67, 0),
405                                    new MethodTypeInfo("f68", 68, 0),
406                                    new MethodTypeInfo("f69", 69, 0),
407                                    new MethodTypeInfo("f70", 70, 0),
408                                    new MethodTypeInfo("f71", 71, 0),
409                                    new MethodTypeInfo("f72", 72, 0),
410                                    new MethodTypeInfo("f73", 73, 0),
411                                    new MethodTypeInfo("f74", 74, 0),
412                                    new MethodTypeInfo("f75", 75, 0),
413                                    new MethodTypeInfo("f76", 76, 0),
414                                    new MethodTypeInfo("f77", 77, 0),
415                                    new MethodTypeInfo("f78", 78, 0),
416                                    new MethodTypeInfo("f79", 79, 0),
417                                    new MethodTypeInfo("f80", 80, 0),
418                                    new MethodTypeInfo("f81", 81, 0),
419                                    new MethodTypeInfo("f82", 82, 0),
420                                    new MethodTypeInfo("f83", 83, 0),
421                                    new MethodTypeInfo("f84", 84, 0),
422                                    new MethodTypeInfo("f85", 85, 0),
423                                    new MethodTypeInfo("f86", 86, 0),
424                                    new MethodTypeInfo("f87", 87, 0),
425                                    new MethodTypeInfo("f88", 88, 0),
426                                    new MethodTypeInfo("f89", 89, 0),
427                                    new MethodTypeInfo("f90", 90, 0),
428                                    new MethodTypeInfo("f91", 91, 0),
429                                    new MethodTypeInfo("f92", 92, 0),
430                                    new MethodTypeInfo("f93", 93, 0),
431                                    new MethodTypeInfo("f94", 94, 0),
432                                    new MethodTypeInfo("f95", 95, 0),
433                                    new MethodTypeInfo("f96", 96, 0),
434                                    new MethodTypeInfo("f97", 97, 0),
435                                    new MethodTypeInfo("f98", 98, 0),
436                                    new MethodTypeInfo("f99", 99, 0),
437                                    new MethodTypeInfo("f100", 100, 0),
438                                    new MethodTypeInfo("f101", 101, 0),
439                                    new MethodTypeInfo("f102", 102, 0),
440                                    new MethodTypeInfo("f103", 103, 0),
441                                    new MethodTypeInfo("f104", 104, 0),
442                                    new MethodTypeInfo("f105", 105, 0),
443                                    new MethodTypeInfo("f106", 106, 0),
444                                    new MethodTypeInfo("f107", 107, 0),
445                                    new MethodTypeInfo("f108", 108, 0),
446                                    new MethodTypeInfo("f109", 109, 0),
447                                    new MethodTypeInfo("f110", 110, 0),
448                                    new MethodTypeInfo("f111", 111, 0),
449                                    new MethodTypeInfo("f112", 112, 0),
450                                    new MethodTypeInfo("f113", 113, 0),
451                                    new MethodTypeInfo("f114", 114, 0),
452                                    new MethodTypeInfo("f115", 115, 0),
453                                    new MethodTypeInfo("f116", 116, 0),
454                                    new MethodTypeInfo("f117", 117, 0),
455                                    new MethodTypeInfo("f118", 118, 0),
456                                    new MethodTypeInfo("f119", 119, 0),
457                                    new MethodTypeInfo("f120", 120, 0),
458                                    new MethodTypeInfo("f121", 121, 0),
459                                    new MethodTypeInfo("f122", 122, 0),
460                                    new MethodTypeInfo("f123", 123, 0),
461                                    new MethodTypeInfo("f124", 124, 0),
462                                    new MethodTypeInfo("f125", 125, 0),
463                                    new MethodTypeInfo("f126", 126, 0),
464                                    new MethodTypeInfo("f127", 127, 0),
465                                    new MethodTypeInfo("f128", 128, 0),
466                                    new MethodTypeInfo("f129", 129, 0),
467                                    new MethodTypeInfo("f130", 130, 0) };
468     }
469 }
470