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