source: josm/trunk/tools/japicc/modules/Internals/RegTests.pm@ 13595

Last change on this file since 13595 was 13595, checked in by Don-vip, 7 years ago

tools update: Groovy 2.4.15, PMD 6.2.0, JAPICC 2.4

File size: 69.5 KB
Line 
1###########################################################################
2# A module with regression test suite
3#
4# Copyright (C) 2016-2018 Andrey Ponomarenko's ABI Laboratory
5#
6# Written by Andrey Ponomarenko
7#
8# This library is free software; you can redistribute it and/or
9# modify it under the terms of the GNU Lesser General Public
10# License as published by the Free Software Foundation; either
11# version 2.1 of the License, or (at your option) any later version.
12#
13# This library is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public
19# License along with this library; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21# MA 02110-1301 USA.
22###########################################################################
23use strict;
24use File::Copy qw(copy);
25
26sub testTool()
27{
28 printMsg("INFO", "\nVerifying detectable Java library changes");
29
30 printMsg("INFO", "Creating test library ...");
31 my $LibName = "libsample_java";
32 if(-d $LibName) {
33 rmtree($LibName);
34 }
35
36 my $PackageName = "TestPackage";
37 my $Path_v1 = "$LibName/$PackageName.v1/$PackageName";
38 mkpath($Path_v1);
39
40 my $Path_v2 = "$LibName/$PackageName.v2/$PackageName";
41 mkpath($Path_v2);
42
43 my $TestsPath = "$LibName/Tests";
44 mkpath($TestsPath);
45
46 # FirstCheckedException
47 my $FirstCheckedException = "package $PackageName;
48 public class FirstCheckedException extends Exception {
49 }";
50 writeFile($Path_v1."/FirstCheckedException.java", $FirstCheckedException);
51 writeFile($Path_v2."/FirstCheckedException.java", $FirstCheckedException);
52
53 # SecondCheckedException
54 my $SecondCheckedException = "package $PackageName;
55 public class SecondCheckedException extends Exception {
56 }";
57 writeFile($Path_v1."/SecondCheckedException.java", $SecondCheckedException);
58 writeFile($Path_v2."/SecondCheckedException.java", $SecondCheckedException);
59
60 # FirstUncheckedException
61 my $FirstUncheckedException = "package $PackageName;
62 public class FirstUncheckedException extends RuntimeException {
63 }";
64 writeFile($Path_v1."/FirstUncheckedException.java", $FirstUncheckedException);
65 writeFile($Path_v2."/FirstUncheckedException.java", $FirstUncheckedException);
66
67 # SecondUncheckedException
68 my $SecondUncheckedException = "package $PackageName;
69 public class SecondUncheckedException extends RuntimeException {
70 }";
71 writeFile($Path_v1."/SecondUncheckedException.java", $SecondUncheckedException);
72 writeFile($Path_v2."/SecondUncheckedException.java", $SecondUncheckedException);
73
74 # BaseAbstractClass
75 my $BaseAbstractClass = "package $PackageName;
76 public abstract class BaseAbstractClass {
77 public Integer field;
78 public Integer someMethod(Integer param) { return param; }
79 public abstract Integer abstractMethod(Integer param);
80 }";
81 writeFile($Path_v1."/BaseAbstractClass.java", $BaseAbstractClass);
82 writeFile($Path_v2."/BaseAbstractClass.java", $BaseAbstractClass);
83
84 # BaseClass
85 my $BaseClass = "package $PackageName;
86 public class BaseClass {
87 public Integer field;
88 public Integer method(Integer param) { return param; }
89 }";
90 writeFile($Path_v1."/BaseClass.java", $BaseClass);
91 writeFile($Path_v2."/BaseClass.java", $BaseClass);
92
93 # BaseClass2
94 my $BaseClass2 = "package $PackageName;
95 public class BaseClass2 {
96 public Integer field2;
97 public Integer method2(Integer param) { return param; }
98 }";
99 writeFile($Path_v1."/BaseClass2.java", $BaseClass2);
100 writeFile($Path_v2."/BaseClass2.java", $BaseClass2);
101
102 # BaseInterface
103 my $BaseInterface = "package $PackageName;
104 public interface BaseInterface {
105 public Integer field = 100;
106 public Integer method(Integer param);
107 }";
108 writeFile($Path_v1."/BaseInterface.java", $BaseInterface);
109 writeFile($Path_v2."/BaseInterface.java", $BaseInterface);
110
111 # BaseInterface2
112 my $BaseInterface2 = "package $PackageName;
113 public interface BaseInterface2 {
114 public Integer field2 = 100;
115 public Integer method2(Integer param);
116 }";
117 writeFile($Path_v1."/BaseInterface2.java", $BaseInterface2);
118 writeFile($Path_v2."/BaseInterface2.java", $BaseInterface2);
119
120 # BaseConstantInterface
121 my $BaseConstantInterface = "package $PackageName;
122 public interface BaseConstantInterface {
123 public Integer CONSTANT = 10;
124 public Integer CONSTANT2 = 100;
125 }";
126 writeFile($Path_v1."/BaseConstantInterface.java", $BaseConstantInterface);
127 writeFile($Path_v2."/BaseConstantInterface.java", $BaseConstantInterface);
128
129 if(cmpVersions($In::Opt{"CompilerVer"}, "1.5")>=0)
130 {
131 # GenericClass1
132 writeFile($Path_v1."/GenericClass1.java",
133 "package $PackageName;
134 public class GenericClass1<T> {
135 public Integer method(T param) { return 0; }
136 }");
137 writeFile($Path_v2."/GenericClass1.java",
138 "package $PackageName;
139 public class GenericClass1<T> {
140 public Integer method(T param) { return 0; }
141 }");
142
143 # GenericClass2
144 writeFile($Path_v1."/GenericClass2.java",
145 "package $PackageName;
146 public class GenericClass2<T> {
147 public void method() { }
148 }");
149 writeFile($Path_v2."/GenericClass2.java",
150 "package $PackageName;
151 public class GenericClass2<T> {
152 public void method() { }
153 }");
154
155 # Class became generic
156 writeFile($Path_v1."/ClassBecameGeneric.java",
157 "package $PackageName;
158 public abstract class ClassBecameGeneric {
159 public ClassBecameGeneric() {}
160 public abstract ClassBecameGeneric doSomething();
161 }");
162 writeFile($Path_v2."/ClassBecameGeneric.java",
163 "package $PackageName;
164 public abstract class ClassBecameGeneric<T> {
165 public ClassBecameGeneric() {}
166 public abstract T doSomething();
167 }");
168
169 writeFile($TestsPath."/Test_ClassBecameGeneric.java",
170 "import $PackageName.*;
171 class GenerifyingClassDerived extends ClassBecameGeneric {
172 public ClassBecameGeneric doSomething() { return new GenerifyingClassDerived(); }
173 public static void main(String[] args) { }
174 }
175 public class Test_ClassBecameGeneric
176 {
177 public static void main(String[] args) {
178 GenerifyingClassDerived X = new GenerifyingClassDerived();
179 ClassBecameGeneric Res = X.doSomething();
180 }
181 }");
182
183 # Class became raw
184 writeFile($Path_v1."/ClassBecameRaw.java",
185 "package $PackageName;
186 public class ClassBecameRaw<T extends String> {
187 public void method(T param) { }
188 }");
189 writeFile($Path_v2."/ClassBecameRaw.java",
190 "package $PackageName;
191 public class ClassBecameRaw {
192 public void method(String param) { }
193 }");
194
195 writeFile($TestsPath."/Test_ClassBecameRaw.java",
196 "import $PackageName.*;
197 public class Test_ClassBecameRaw
198 {
199 public static void main(String[] args) {
200 ClassBecameRaw<String> X = new ClassBecameRaw<String>();
201 X.method(\"XXX\");
202 }
203 }");
204
205 # Interface became generic
206 writeFile($Path_v1."/InterfaceBecameGeneric.java",
207 "package $PackageName;
208 public interface InterfaceBecameGeneric {
209 public void method();
210 }");
211 writeFile($Path_v2."/InterfaceBecameGeneric.java",
212 "package $PackageName;
213 public interface InterfaceBecameGeneric<T> {
214 public void method();
215 }");
216
217 # Interface became raw
218 writeFile($Path_v1."/InterfaceBecameRaw.java",
219 "package $PackageName;
220 public interface InterfaceBecameRaw<T> {
221 public void method();
222 }");
223 writeFile($Path_v2."/InterfaceBecameRaw.java",
224 "package $PackageName;
225 public interface InterfaceBecameRaw {
226 public void method();
227 }");
228
229 writeFile($TestsPath."/Test_InterfaceBecameRaw.java",
230 "import $PackageName.*;
231 class InterfaceBecameRawDerived implements InterfaceBecameRaw<String> {
232 public void method() { }
233 public static void main(String[] args) { }
234 }
235 public class Test_InterfaceBecameRaw
236 {
237 public static void main(String[] args) {
238 InterfaceBecameRawDerived X = new InterfaceBecameRawDerived();
239 X.method();
240 }
241 }");
242
243 # Changed generic super-class
244 writeFile($Path_v1."/GenericSuperClassChanged.java",
245 "package $PackageName;
246 public class GenericSuperClassChanged extends GenericClass1<String> {
247 public Integer method() { return 0; }
248 }");
249 writeFile($Path_v2."/GenericSuperClassChanged.java",
250 "package $PackageName;
251 public class GenericSuperClassChanged extends GenericClass1<Integer> {
252 public Integer method() { return 0; }
253 }");
254
255 # Extending class with generic parameters
256 writeFile($Path_v1."/ExtendingClassWithGeneric.java",
257 "package $PackageName;
258 public class ExtendingClassWithGeneric {
259 public void method() { }
260 }");
261 writeFile($Path_v2."/ExtendingClassWithGeneric.java",
262 "package $PackageName;
263 public class ExtendingClassWithGeneric extends GenericClass2<String>
264 {
265 }");
266
267 # Renamed generic parameter
268 writeFile($Path_v1."/RenamedGenericParameter.java",
269 "package $PackageName;
270 public class RenamedGenericParameter<A extends String> {
271 public void method(A param) { }
272 }");
273 writeFile($Path_v2."/RenamedGenericParameter.java",
274 "package $PackageName;
275 public class RenamedGenericParameter<B extends String> {
276 public void method(B param) { }
277 }");
278
279 # Changed field type by introducing of a generic parameter
280 writeFile($Path_v1."/ChangedFieldTypeByGenericParam.java",
281 "package $PackageName;
282 public class ChangedFieldTypeByGenericParam {
283 public ChangedFieldTypeByGenericParam(String param) { f=param; }
284 public void method() { }
285 public String f;
286 }");
287 writeFile($Path_v2."/ChangedFieldTypeByGenericParam.java",
288 "package $PackageName;
289 public class ChangedFieldTypeByGenericParam<T> {
290 public ChangedFieldTypeByGenericParam(T param) { f=param; }
291 public void method() { }
292 public T f;
293 }");
294
295 writeFile($Path_v1."/TestGeneric.java",
296 "package $PackageName;
297 public class TestGeneric {
298 public ChangedFieldTypeByGenericParam get1() { return new ChangedFieldTypeByGenericParam(\"XXX\"); }
299 public ChangedFieldTypeByGenericParam get2() { return new ChangedFieldTypeByGenericParam(\"XXX\"); }
300 }");
301 writeFile($Path_v2."/TestGeneric.java",
302 "package $PackageName;
303 public class TestGeneric {
304 public ChangedFieldTypeByGenericParam<String> get1() { return new ChangedFieldTypeByGenericParam<String>(\"XXX\"); }
305 public ChangedFieldTypeByGenericParam<Integer> get2() { return new ChangedFieldTypeByGenericParam<Integer>(0); }
306 }");
307
308 writeFile($TestsPath."/Test_ChangedFieldTypeByGenericParam.java",
309 "import $PackageName.*;
310 public class Test_ChangedFieldTypeByGenericParam
311 {
312 public static void main(String[] args)
313 {
314 TestGeneric X = new TestGeneric();
315 ChangedFieldTypeByGenericParam Res1 = X.get1();
316 ChangedFieldTypeByGenericParam Res2 = X.get2();
317 Res1.f = Res2.f;
318 }
319 }");
320
321 # Changed constructor after generifying
322 writeFile($Path_v1."/ChangedCtorAfterGenerifying.java",
323 "package $PackageName;
324 public class ChangedCtorAfterGenerifying {
325 public ChangedCtorAfterGenerifying(String param) { }
326 public String f;
327 }");
328 writeFile($Path_v2."/ChangedCtorAfterGenerifying.java",
329 "package $PackageName;
330 public class ChangedCtorAfterGenerifying<T> {
331 public ChangedCtorAfterGenerifying(T param) { }
332 public T f;
333 }");
334
335 writeFile($TestsPath."/Test_ChangedCtorAfterGenerifying.java",
336 "import $PackageName.*;
337 public class Test_ChangedCtorAfterGenerifying
338 {
339 public static void main(String[] args) {
340 ChangedCtorAfterGenerifying X = new ChangedCtorAfterGenerifying(\"XXX\");
341 }
342 }");
343
344 # Array to variable arity
345 writeFile($Path_v1."/ArrayToVariableArity.java",
346 "package $PackageName;
347 public class ArrayToVariableArity {
348 public void method(Integer x, String[] y) { }
349 }");
350 writeFile($Path_v2."/ArrayToVariableArity.java",
351 "package $PackageName;
352 public class ArrayToVariableArity {
353 public void method(Integer x, String... y) { }
354 }");
355
356 writeFile($TestsPath."/Test_ArrayToVariableArity.java",
357 "import $PackageName.*;
358 public class Test_ArrayToVariableArity
359 {
360 public static void main(String[] args) {
361 ArrayToVariableArity X = new ArrayToVariableArity();
362 X.method(0, new String[]{\"a\", \"b\"});
363 }
364 }");
365
366 # Variable arity to array
367 writeFile($Path_v1."/VariableArityToArray.java",
368 "package $PackageName;
369 public class VariableArityToArray {
370 public void method(Integer x, String... y) { }
371 }");
372 writeFile($Path_v2."/VariableArityToArray.java",
373 "package $PackageName;
374 public class VariableArityToArray {
375 public void method(Integer x, String[] y) { }
376 }");
377
378 writeFile($TestsPath."/Test_VariableArityToArray.java",
379 "import $PackageName.*;
380 public class Test_VariableArityToArray
381 {
382 public static void main(String[] args) {
383 VariableArityToArray X = new VariableArityToArray();
384 X.method(0, \"a\", \"b\");
385 }
386 }");
387
388 # Added vararg parameter
389 writeFile($Path_v1."/AddedVarargParam.java",
390 "package $PackageName;
391 public class AddedVarargParam {
392 public void method(Integer x, String... y) { }
393 }");
394 writeFile($Path_v2."/AddedVarargParam.java",
395 "package $PackageName;
396 public class AddedVarargParam {
397 public void method(Integer x, String... y) { }
398 }");
399
400 writeFile($TestsPath."/Test_AddedVarargParam.java",
401 "import $PackageName.*;
402 public class Test_AddedVarargParam
403 {
404 public static void main(String[] args) {
405 AddedVarargParam X = new AddedVarargParam();
406 X.method(0);
407 }
408 }");
409
410 # Removed_Annotation
411 writeFile($Path_v1."/RemovedAnnotation.java",
412 "package $PackageName;
413 public \@interface RemovedAnnotation {
414 }");
415
416 writeFile($TestsPath."/Test_RemovedAnnotation.java",
417 "import $PackageName.*;
418 public class Test_RemovedAnnotation {
419 public static void main(String[] args) {
420 testMethod();
421 }
422
423 \@RemovedAnnotation
424 static void testMethod() {
425 }
426 }");
427
428 # Changed Annotation
429 writeFile($Path_v1."/ChangedAnnotation.java",
430 "package $PackageName;
431
432 enum MyEnum {
433 SUNDAY, MONDAY
434 }
435
436 public \@interface ChangedAnnotation {
437 String value();
438 String datatype() default \"Str\";
439 int num1() default 1;
440 String[] values() default {\"Alice\", \"Bob\", \"Cindy\"};
441 int[] nums() default {1, 2, 3};
442 String safe_change() default \"Str\";
443 MyEnum day() default MyEnum.SUNDAY;
444 short num2() default 1;
445 long num3() default 1;
446 byte num4() default 1;
447 float num5() default 1.5f;
448 double num6() default 1.5;
449 boolean bit() default true;
450 char ch() default 'A';
451 }");
452
453 writeFile($Path_v2."/ChangedAnnotation.java",
454 "package $PackageName;
455
456 enum MyEnum {
457 SUNDAY, MONDAY
458 }
459
460 public \@interface ChangedAnnotation {
461 String value() default \"Str\";
462 String datatype();
463 int[] values();
464 int[] nums() default {1, 2};
465 int[] new_default_param() default {1, 2};
466 int[] new_param();
467 String[] safe_change() default {\"Str\"};
468 MyEnum day() default MyEnum.MONDAY;
469 }");
470
471 writeFile($TestsPath."/Test_ChangedAnnotation.java",
472 "import $PackageName.*;
473 public class Test_ChangedAnnotation {
474 public static void main(String[] args) {
475 testMethod();
476 }
477
478 \@ChangedAnnotation(value=\"Val\")
479 static void testMethod() {
480 }
481 }");
482
483 # Beta Annotation
484 writeFile($Path_v1."/Beta.java",
485 "package $PackageName;
486 public \@interface Beta {
487 }");
488
489 writeFile($Path_v2."/Beta.java",
490 "package $PackageName;
491 public \@interface Beta {
492 }");
493
494 # Removed_Method (Beta method)
495 writeFile($Path_v1."/RemovedBetaMethod.java",
496 "package $PackageName;
497 public class RemovedBetaMethod
498 {
499 \@Beta
500 public Integer someMethod() {
501 return 0;
502 }
503 }");
504 writeFile($Path_v2."/RemovedBetaMethod.java",
505 "package $PackageName;
506 public class RemovedBetaMethod {
507 }");
508
509 # Removed_Method (from Beta class)
510 writeFile($Path_v1."/RemovedMethodFromBetaClass.java",
511 "package $PackageName;
512 \@Beta
513 public class RemovedMethodFromBetaClass
514 {
515 public Integer someMethod() {
516 return 0;
517 }
518 }");
519 writeFile($Path_v2."/RemovedMethodFromBetaClass.java",
520 "package $PackageName;
521 \@Beta
522 public class RemovedMethodFromBetaClass {
523 }");
524
525 # Removed_Class (Beta)
526 writeFile($Path_v1."/RemovedBetaClass.java",
527 "package $PackageName;
528 \@Beta
529 public class RemovedBetaClass
530 {
531 public Integer someMethod() {
532 return 0;
533 }
534 }");
535 }
536
537 # Abstract_Method_Added_Checked_Exception
538 writeFile($Path_v1."/AbstractMethodAddedCheckedException.java",
539 "package $PackageName;
540 public abstract class AbstractMethodAddedCheckedException {
541 public abstract Integer someMethod() throws FirstCheckedException;
542 }");
543 writeFile($Path_v2."/AbstractMethodAddedCheckedException.java",
544 "package $PackageName;
545 public abstract class AbstractMethodAddedCheckedException {
546 public abstract Integer someMethod() throws FirstCheckedException, SecondCheckedException;
547 }");
548
549 # Abstract_Method_Removed_Checked_Exception
550 writeFile($Path_v1."/AbstractMethodRemovedCheckedException.java",
551 "package $PackageName;
552 public abstract class AbstractMethodRemovedCheckedException {
553 public abstract Integer someMethod() throws FirstCheckedException, SecondCheckedException;
554 }");
555 writeFile($Path_v2."/AbstractMethodRemovedCheckedException.java",
556 "package $PackageName;
557 public abstract class AbstractMethodRemovedCheckedException {
558 public abstract Integer someMethod() throws FirstCheckedException;
559 }");
560
561 # NonAbstract_Method_Added_Checked_Exception
562 writeFile($Path_v1."/NonAbstractMethodAddedCheckedException.java",
563 "package $PackageName;
564 public class NonAbstractMethodAddedCheckedException {
565 public Integer someMethod() throws FirstCheckedException {
566 return 10;
567 }
568 }");
569 writeFile($Path_v2."/NonAbstractMethodAddedCheckedException.java",
570 "package $PackageName;
571 public class NonAbstractMethodAddedCheckedException {
572 public Integer someMethod() throws FirstCheckedException, SecondCheckedException {
573 return 10;
574 }
575 }");
576
577 # NonAbstract_Method_Removed_Checked_Exception
578 writeFile($Path_v1."/NonAbstractMethodRemovedCheckedException.java",
579 "package $PackageName;
580 public class NonAbstractMethodRemovedCheckedException {
581 public Integer someMethod() throws FirstCheckedException, SecondCheckedException {
582 return 10;
583 }
584 }");
585 writeFile($Path_v2."/NonAbstractMethodRemovedCheckedException.java",
586 "package $PackageName;
587 public class NonAbstractMethodRemovedCheckedException {
588 public Integer someMethod() throws FirstCheckedException {
589 return 10;
590 }
591 }");
592
593 # Added_Unchecked_Exception
594 writeFile($Path_v1."/AddedUncheckedException.java",
595 "package $PackageName;
596 public class AddedUncheckedException {
597 public Integer someMethod() throws FirstUncheckedException {
598 return 10;
599 }
600 }");
601 writeFile($Path_v2."/AddedUncheckedException.java",
602 "package $PackageName;
603 public class AddedUncheckedException {
604 public Integer someMethod() throws FirstUncheckedException, SecondUncheckedException, NullPointerException {
605 return 10;
606 }
607 }");
608
609 # Removed_Unchecked_Exception
610 writeFile($Path_v1."/RemovedUncheckedException.java",
611 "package $PackageName;
612 public class RemovedUncheckedException {
613 public Integer someMethod() throws FirstUncheckedException, SecondUncheckedException, NullPointerException {
614 return 10;
615 }
616 }");
617 writeFile($Path_v2."/RemovedUncheckedException.java",
618 "package $PackageName;
619 public class RemovedUncheckedException {
620 public Integer someMethod() throws FirstUncheckedException {
621 return 10;
622 }
623 }");
624
625 # Changed_Method_Return_From_Void
626 writeFile($Path_v1."/ChangedMethodReturnFromVoid.java",
627 "package $PackageName;
628 public class ChangedMethodReturnFromVoid {
629 public void changedMethod(Integer param1) { }
630 }");
631 writeFile($Path_v2."/ChangedMethodReturnFromVoid.java",
632 "package $PackageName;
633 public class ChangedMethodReturnFromVoid {
634 public Integer changedMethod(Integer param1){
635 return param1;
636 }
637 }");
638
639 writeFile($TestsPath."/Test_ChangedMethodReturnFromVoid.java",
640 "import $PackageName.*;
641 public class Test_ChangedMethodReturnFromVoid {
642 public static void main(String[] args) {
643 ChangedMethodReturnFromVoid X = new ChangedMethodReturnFromVoid();
644 X.changedMethod(1);
645 }
646 }");
647
648 # Changed_Method_Return
649 writeFile($Path_v1."/ChangedMethodReturn.java",
650 "package $PackageName;
651 public class ChangedMethodReturn {
652 public Integer changedMethod(Integer param) { return 0; }
653 }");
654 writeFile($Path_v2."/ChangedMethodReturn.java",
655 "package $PackageName;
656 public class ChangedMethodReturn {
657 public String changedMethod(Integer param) { return \"XXX\"; }
658 }");
659
660 writeFile($TestsPath."/Test_ChangedMethodReturn.java",
661 "import $PackageName.*;
662 public class Test_ChangedMethodReturn {
663 public static void main(String[] args) {
664 ChangedMethodReturn X = new ChangedMethodReturn();
665 Integer Res = X.changedMethod(0);
666 }
667 }");
668
669 # Added_Method
670 writeFile($Path_v1."/AddedMethod.java",
671 "package $PackageName;
672 public class AddedMethod {
673 public Integer field = 100;
674 }");
675 writeFile($Path_v2."/AddedMethod.java",
676 "package $PackageName;
677 public class AddedMethod {
678 public Integer field = 100;
679 public Integer addedMethod(Integer param1, String[] param2) { return param1; }
680 public static String[] addedStaticMethod(String[] param) { return param; }
681 }");
682
683 # Added_Method (Constructor)
684 writeFile($Path_v1."/AddedConstructor.java",
685 "package $PackageName;
686 public class AddedConstructor {
687 public Integer field = 100;
688 }");
689 writeFile($Path_v2."/AddedConstructor.java",
690 "package $PackageName;
691 public class AddedConstructor {
692 public Integer field = 100;
693 public AddedConstructor() { }
694 public AddedConstructor(Integer x, String y) { }
695 }");
696
697 # Class_Added_Field
698 writeFile($Path_v1."/ClassAddedField.java",
699 "package $PackageName;
700 public class ClassAddedField {
701 public Integer otherField;
702 }");
703 writeFile($Path_v2."/ClassAddedField.java",
704 "package $PackageName;
705 public class ClassAddedField {
706 public Integer addedField;
707 public Integer otherField;
708 }");
709
710 # Interface_Added_Field
711 writeFile($Path_v1."/InterfaceAddedField.java",
712 "package $PackageName;
713 public interface InterfaceAddedField {
714 public Integer method();
715 }");
716 writeFile($Path_v2."/InterfaceAddedField.java",
717 "package $PackageName;
718 public interface InterfaceAddedField {
719 public Integer addedField = 100;
720 public Integer method();
721 }");
722
723 # Removed_NonConstant_Field (Class)
724 writeFile($Path_v1."/ClassRemovedField.java",
725 "package $PackageName;
726 public class ClassRemovedField {
727 public Integer removedField;
728 public Integer otherField;
729 }");
730 writeFile($Path_v2."/ClassRemovedField.java",
731 "package $PackageName;
732 public class ClassRemovedField {
733 public Integer otherField;
734 }");
735
736 writeFile($TestsPath."/Test_ClassRemovedField.java",
737 "import $PackageName.*;
738 public class Test_ClassRemovedField {
739 public static void main(String[] args) {
740 ClassRemovedField X = new ClassRemovedField();
741 Integer Copy = X.removedField;
742 }
743 }");
744
745 # Removed_Constant_Field (Interface)
746 writeFile($Path_v1."/InterfaceRemovedConstantField.java",
747 "package $PackageName;
748 public interface InterfaceRemovedConstantField {
749 public String someMethod();
750 public int removedField_Int = 1000;
751 public String removedField_Str = \"Value\";
752 }");
753 writeFile($Path_v2."/InterfaceRemovedConstantField.java",
754 "package $PackageName;
755 public interface InterfaceRemovedConstantField {
756 public String someMethod();
757 }");
758
759 # Removed_NonConstant_Field (Interface)
760 writeFile($Path_v1."/InterfaceRemovedField.java",
761 "package $PackageName;
762 public interface InterfaceRemovedField {
763 public String someMethod();
764 public BaseClass removedField = new BaseClass();
765 }");
766 writeFile($Path_v2."/InterfaceRemovedField.java",
767 "package $PackageName;
768 public interface InterfaceRemovedField {
769 public String someMethod();
770 }");
771
772 # Renamed_Field
773 writeFile($Path_v1."/RenamedField.java",
774 "package $PackageName;
775 public class RenamedField {
776 public String oldName;
777 }");
778 writeFile($Path_v2."/RenamedField.java",
779 "package $PackageName;
780 public class RenamedField {
781 public String newName;
782 }");
783
784 # Renamed_Constant_Field
785 writeFile($Path_v1."/RenamedConstantField.java",
786 "package $PackageName;
787 public class RenamedConstantField {
788 public final String oldName = \"Value\";
789 }");
790 writeFile($Path_v2."/RenamedConstantField.java",
791 "package $PackageName;
792 public class RenamedConstantField {
793 public final String newName = \"Value\";
794 }");
795
796 # Changed_Field_Type
797 writeFile($Path_v1."/ChangedFieldType.java",
798 "package $PackageName;
799 public class ChangedFieldType {
800 public String fieldName;
801 }");
802 writeFile($Path_v2."/ChangedFieldType.java",
803 "package $PackageName;
804 public class ChangedFieldType {
805 public Integer fieldName;
806 }");
807
808 writeFile($TestsPath."/Test_ChangedFieldType.java",
809 "import $PackageName.*;
810 public class Test_ChangedFieldType {
811 public static void main(String[] args) {
812 ChangedFieldType X = new ChangedFieldType();
813 String R = X.fieldName;
814 }
815 }");
816
817 # Changed_Field_Access
818 writeFile($Path_v1."/ChangedFieldAccess.java",
819 "package $PackageName;
820 public class ChangedFieldAccess {
821 public String fieldName;
822 }");
823 writeFile($Path_v2."/ChangedFieldAccess.java",
824 "package $PackageName;
825 public class ChangedFieldAccess {
826 private String fieldName;
827 }");
828
829 # Changed_Final_Field_Value
830 writeFile($Path_v1."/ChangedFinalFieldValue.java",
831 "package $PackageName;
832 public class ChangedFinalFieldValue {
833 enum MyEnum {
834 ONE, TWO
835 }
836 public final int field1 = 1;
837 public final String field2 = \" \";
838 public final MyEnum field3 = MyEnum.ONE;
839 }");
840 writeFile($Path_v2."/ChangedFinalFieldValue.java",
841 "package $PackageName;
842 public class ChangedFinalFieldValue {
843 enum MyEnum {
844 ONE, TWO
845 }
846 public final int field1 = 2;
847 public final String field2 = \"newValue\";
848 public final MyEnum field3 = MyEnum.TWO;
849 }");
850
851 # NonConstant_Field_Became_Static
852 writeFile($Path_v1."/NonConstantFieldBecameStatic.java",
853 "package $PackageName;
854 public class NonConstantFieldBecameStatic {
855 public String fieldName;
856 }");
857 writeFile($Path_v2."/NonConstantFieldBecameStatic.java",
858 "package $PackageName;
859 public class NonConstantFieldBecameStatic {
860 public static String fieldName;
861 }");
862
863 writeFile($TestsPath."/Test_NonConstantFieldBecameStatic.java",
864 "import $PackageName.*;
865 public class Test_NonConstantFieldBecameStatic {
866 public static void main(String[] args) {
867 NonConstantFieldBecameStatic X = new NonConstantFieldBecameStatic();
868 String R = X.fieldName;
869 }
870 }");
871
872 # NonConstant_Field_Became_NonStatic
873 writeFile($Path_v1."/NonConstantFieldBecameNonStatic.java",
874 "package $PackageName;
875 public class NonConstantFieldBecameNonStatic {
876 public static String fieldName;
877 }");
878 writeFile($Path_v2."/NonConstantFieldBecameNonStatic.java",
879 "package $PackageName;
880 public class NonConstantFieldBecameNonStatic {
881 public String fieldName;
882 }");
883
884 # Constant_Field_Became_NonStatic
885 writeFile($Path_v1."/ConstantFieldBecameNonStatic.java",
886 "package $PackageName;
887 public class ConstantFieldBecameNonStatic {
888 public final static String fieldName = \"Value\";
889 }");
890 writeFile($Path_v2."/ConstantFieldBecameNonStatic.java",
891 "package $PackageName;
892 public class ConstantFieldBecameNonStatic {
893 public final String fieldName = \"Value\";
894 }");
895
896 # Field_Became_Final
897 writeFile($Path_v1."/FieldBecameFinal.java",
898 "package $PackageName;
899 public class FieldBecameFinal {
900 public String fieldName;
901 }");
902 writeFile($Path_v2."/FieldBecameFinal.java",
903 "package $PackageName;
904 public class FieldBecameFinal {
905 public final String fieldName = \"Value\";
906 }");
907
908 # Field_Became_NonFinal
909 writeFile($Path_v1."/FieldBecameNonFinal.java",
910 "package $PackageName;
911 public class FieldBecameNonFinal {
912 public final String fieldName = \"Value\";
913 }");
914 writeFile($Path_v2."/FieldBecameNonFinal.java",
915 "package $PackageName;
916 public class FieldBecameNonFinal {
917 public String fieldName;
918 }");
919
920 # Removed_Method
921 writeFile($Path_v1."/RemovedMethod.java",
922 "package $PackageName;
923 public class RemovedMethod {
924 public Integer field = 100;
925 public Integer removedMethod(Integer param1, String param2) { return param1; }
926 public static Integer removedStaticMethod(Integer param) { return param; }
927 }");
928 writeFile($Path_v2."/RemovedMethod.java",
929 "package $PackageName;
930 public class RemovedMethod {
931 public Integer field = 100;
932 }");
933
934 # Removed protected method from final class
935 writeFile($Path_v1."/RemovedProtectedMethodFromFinalClass.java",
936 "package $PackageName;
937 public final class RemovedProtectedMethodFromFinalClass {
938 protected void removedMethod(Integer param) { }
939 }");
940 writeFile($Path_v2."/RemovedProtectedMethodFromFinalClass.java",
941 "package $PackageName;
942 public final class RemovedProtectedMethodFromFinalClass {
943 }");
944
945 # Removed_Method (move up to java.lang.Object)
946 writeFile($Path_v1."/MoveUpToJavaLangObject.java",
947 "package $PackageName;
948 public class MoveUpToJavaLangObject extends java.lang.Object {
949 public int hashCode() { return 0; }
950 }");
951 writeFile($Path_v2."/MoveUpToJavaLangObject.java",
952 "package $PackageName;
953 public class MoveUpToJavaLangObject extends java.lang.Object {
954 }");
955
956 writeFile($TestsPath."/Test_MoveUpToJavaLangObject.java",
957 "import $PackageName.*;
958 public class Test_MoveUpToJavaLangObject {
959 public static void main(String[] args) {
960 MoveUpToJavaLangObject X = new MoveUpToJavaLangObject();
961 int R = X.hashCode();
962 }
963 }");
964
965 # Removed_Method (Deprecated)
966 writeFile($Path_v1."/RemovedDeprecatedMethod.java",
967 "package $PackageName;
968 public class RemovedDeprecatedMethod {
969 public Integer field = 100;
970 public Integer otherMethod(Integer param) { return param; }
971 \@Deprecated
972 public Integer removedMethod(Integer param1, String param2) { return param1; }
973 }");
974 writeFile($Path_v2."/RemovedDeprecatedMethod.java",
975 "package $PackageName;
976 public class RemovedDeprecatedMethod {
977 public Integer field = 100;
978 public Integer otherMethod(Integer param) { return param; }
979 }");
980
981 # Interface_Removed_Abstract_Method
982 writeFile($Path_v1."/InterfaceRemovedAbstractMethod.java",
983 "package $PackageName;
984 public interface InterfaceRemovedAbstractMethod extends BaseInterface, BaseInterface2 {
985 public void removedMethod(Integer param1, java.io.ObjectOutput param2);
986 public void someMethod(Integer param);
987 }");
988 writeFile($Path_v2."/InterfaceRemovedAbstractMethod.java",
989 "package $PackageName;
990 public interface InterfaceRemovedAbstractMethod extends BaseInterface, BaseInterface2 {
991 public void someMethod(Integer param);
992 }");
993
994 # Interface_Removed_Abstract_Method (Last)
995 writeFile($Path_v1."/InterfaceRemovedLastAbstractMethod.java",
996 "package $PackageName;
997 public interface InterfaceRemovedLastAbstractMethod {
998 public void removedMethod(Integer param);
999 }");
1000 writeFile($Path_v2."/InterfaceRemovedLastAbstractMethod.java",
1001 "package $PackageName;
1002 public interface InterfaceRemovedLastAbstractMethod {
1003 }");
1004
1005 writeFile($TestsPath."/Test_InterfaceRemovedLastAbstractMethod.java",
1006 "import $PackageName.*;
1007 class InterfaceRemovedLastAbstractMethodDerived implements InterfaceRemovedLastAbstractMethod
1008 {
1009 public void removedMethod(Integer param) { }
1010 public static void main(String[] args) { }
1011 };
1012
1013 public class Test_InterfaceRemovedLastAbstractMethod
1014 {
1015 public static void main(String[] args)
1016 {
1017 InterfaceRemovedLastAbstractMethod Obj = new InterfaceRemovedLastAbstractMethodDerived();
1018 Obj.removedMethod(0);
1019 }
1020 }");
1021
1022 # Interface_Added_Abstract_Method
1023 writeFile($Path_v1."/InterfaceAddedAbstractMethod.java",
1024 "package $PackageName;
1025 public interface InterfaceAddedAbstractMethod extends BaseInterface, BaseInterface2 {
1026 public void someMethod(Integer param);
1027 }");
1028 writeFile($Path_v2."/InterfaceAddedAbstractMethod.java",
1029 "package $PackageName;
1030 public interface InterfaceAddedAbstractMethod extends BaseInterface, BaseInterface2 {
1031 public void someMethod(Integer param);
1032 public Integer addedMethod(Integer param);
1033 }");
1034
1035 # Interface_Added_Default_Method
1036 writeFile($Path_v1."/InterfaceAddedDefaultMethod.java",
1037 "package $PackageName;
1038 public interface InterfaceAddedDefaultMethod {
1039 public void someMethod(Integer param);
1040 }");
1041 writeFile($Path_v2."/InterfaceAddedDefaultMethod.java",
1042 "package $PackageName;
1043 public interface InterfaceAddedDefaultMethod {
1044 public void someMethod(Integer param);
1045 default Integer addedMethod(Integer param) { return 0; }
1046 }");
1047
1048 # Method_Became_NonDefault
1049 writeFile($Path_v1."/MethodBecameNonDefault.java",
1050 "package $PackageName;
1051 public interface MethodBecameNonDefault {
1052 default Integer someMethod(Integer param) { return 0; }
1053 }");
1054 writeFile($Path_v2."/MethodBecameNonDefault.java",
1055 "package $PackageName;
1056 public interface MethodBecameNonDefault {
1057 public Integer someMethod(Integer param);
1058 }");
1059
1060 writeFile($TestsPath."/Test_MethodBecameNonDefault.java",
1061 "import $PackageName.*;
1062 class Class_MethodBecameNonDefault implements MethodBecameNonDefault {
1063 public static void main(String[] args) { }
1064 };
1065
1066 public class Test_MethodBecameNonDefault
1067 {
1068 public static void main(String[] args)
1069 {
1070 Class_MethodBecameNonDefault Obj = new Class_MethodBecameNonDefault();
1071 Integer Res = Obj.someMethod(0);
1072 }
1073 }");
1074
1075 # Class_Became_Interface
1076 writeFile($Path_v1."/ClassBecameInterface.java",
1077 "package $PackageName;
1078 public class ClassBecameInterface extends BaseClass {
1079 public Integer someMethod(Integer param) {
1080 return param;
1081 }
1082 }");
1083 writeFile($Path_v2."/ClassBecameInterface.java",
1084 "package $PackageName;
1085 public interface ClassBecameInterface extends BaseInterface, BaseInterface2 {
1086 public Integer someMethod(Integer param);
1087 }");
1088
1089 # Added_Super_Class
1090 writeFile($Path_v1."/AddedSuperClass.java",
1091 "package $PackageName;
1092 public class AddedSuperClass {
1093 public Integer someMethod(Integer param) {
1094 return param;
1095 }
1096 }");
1097 writeFile($Path_v2."/AddedSuperClass.java",
1098 "package $PackageName;
1099 public class AddedSuperClass extends BaseClass {
1100 public Integer someMethod(Integer param) {
1101 return param;
1102 }
1103 }");
1104
1105 # Abstract_Class_Added_Super_Abstract_Class
1106 writeFile($Path_v1."/AbstractClassAddedSuperAbstractClass.java",
1107 "package $PackageName;
1108 public abstract class AbstractClassAddedSuperAbstractClass {
1109 public Integer someMethod(Integer param) {
1110 return param;
1111 }
1112 }");
1113 writeFile($Path_v2."/AbstractClassAddedSuperAbstractClass.java",
1114 "package $PackageName;
1115 public abstract class AbstractClassAddedSuperAbstractClass extends BaseAbstractClass {
1116 public Integer someMethod(Integer param) {
1117 return param;
1118 }
1119 }");
1120
1121 # Removed_Super_Class
1122 writeFile($Path_v1."/RemovedSuperClass.java",
1123 "package $PackageName;
1124 public class RemovedSuperClass extends BaseClass {
1125 public Integer someMethod(Integer param) {
1126 return param;
1127 }
1128 }");
1129 writeFile($Path_v2."/RemovedSuperClass.java",
1130 "package $PackageName;
1131 public class RemovedSuperClass {
1132 public Integer someMethod(Integer param) {
1133 return param;
1134 }
1135 }");
1136
1137 # Changed_Super_Class
1138 writeFile($Path_v1."/ChangedSuperClass.java",
1139 "package $PackageName;
1140 public class ChangedSuperClass extends BaseClass {
1141 public Integer someMethod(Integer param) {
1142 return param;
1143 }
1144 }");
1145 writeFile($Path_v2."/ChangedSuperClass.java",
1146 "package $PackageName;
1147 public class ChangedSuperClass extends BaseClass2 {
1148 public Integer someMethod(Integer param) {
1149 return param;
1150 }
1151 }");
1152
1153 # Abstract_Class_Added_Super_Interface
1154 writeFile($Path_v1."/AbstractClassAddedSuperInterface.java",
1155 "package $PackageName;
1156 public abstract class AbstractClassAddedSuperInterface implements BaseInterface {
1157 public Integer method(Integer param) {
1158 return param;
1159 }
1160 }");
1161 writeFile($Path_v2."/AbstractClassAddedSuperInterface.java",
1162 "package $PackageName;
1163 public abstract class AbstractClassAddedSuperInterface implements BaseInterface, BaseInterface2 {
1164 public Integer method(Integer param) {
1165 return param;
1166 }
1167 }");
1168
1169 # Abstract_Class_Added_Super_Interface_With_Implemented_Methods
1170 writeFile($Path_v1."/AbstractClassAddedSuperInterfaceWithImplementedMethods.java",
1171 "package $PackageName;
1172 public abstract class AbstractClassAddedSuperInterfaceWithImplementedMethods implements BaseInterface {
1173 public Integer method(Integer param) {
1174 return param;
1175 }
1176 public Integer method2(Integer param) {
1177 return param;
1178 }
1179 }");
1180 writeFile($Path_v2."/AbstractClassAddedSuperInterfaceWithImplementedMethods.java",
1181 "package $PackageName;
1182 public abstract class AbstractClassAddedSuperInterfaceWithImplementedMethods implements BaseInterface, BaseInterface2 {
1183 public Integer method(Integer param) {
1184 return param;
1185 }
1186 public Integer method2(Integer param) {
1187 return param;
1188 }
1189 }");
1190
1191 # Class_Removed_Super_Interface
1192 writeFile($Path_v1."/ClassRemovedSuperInterface.java",
1193 "package $PackageName;
1194 public class ClassRemovedSuperInterface implements BaseInterface, BaseInterface2 {
1195 public Integer method(Integer param) {
1196 return param;
1197 }
1198 public Integer method2(Integer param) {
1199 return param;
1200 }
1201 }");
1202 writeFile($Path_v2."/ClassRemovedSuperInterface.java",
1203 "package $PackageName;
1204 public class ClassRemovedSuperInterface implements BaseInterface {
1205 public Integer method(Integer param) {
1206 return param;
1207 }
1208 public Integer method2(Integer param) {
1209 return param;
1210 }
1211 }");
1212
1213 writeFile($TestsPath."/Test_ClassRemovedSuperInterface.java",
1214 "import $PackageName.*;
1215 public class Test_ClassRemovedSuperInterface
1216 {
1217 public static void main(String[] args)
1218 {
1219 ClassRemovedSuperInterface Obj = new ClassRemovedSuperInterface();
1220 Integer Res = Obj.method2(0);
1221 }
1222 }");
1223
1224 # Interface_Added_Super_Interface
1225 writeFile($Path_v1."/InterfaceAddedSuperInterface.java",
1226 "package $PackageName;
1227 public interface InterfaceAddedSuperInterface extends BaseInterface {
1228 public Integer someMethod(Integer param);
1229 }");
1230 writeFile($Path_v2."/InterfaceAddedSuperInterface.java",
1231 "package $PackageName;
1232 public interface InterfaceAddedSuperInterface extends BaseInterface, BaseInterface2 {
1233 public Integer someMethod(Integer param);
1234 }");
1235
1236 # Interface_Added_Super_Constant_Interface
1237 writeFile($Path_v1."/InterfaceAddedSuperConstantInterface.java",
1238 "package $PackageName;
1239 public interface InterfaceAddedSuperConstantInterface extends BaseInterface {
1240 public Integer someMethod(Integer param);
1241 }");
1242 writeFile($Path_v2."/InterfaceAddedSuperConstantInterface.java",
1243 "package $PackageName;
1244 public interface InterfaceAddedSuperConstantInterface extends BaseInterface, BaseConstantInterface {
1245 public Integer someMethod(Integer param);
1246 }");
1247
1248 # Interface_Removed_Super_Interface
1249 writeFile($Path_v1."/InterfaceRemovedSuperInterface.java",
1250 "package $PackageName;
1251 public interface InterfaceRemovedSuperInterface extends BaseInterface, BaseInterface2 {
1252 public Integer someMethod(Integer param);
1253 }");
1254 writeFile($Path_v2."/InterfaceRemovedSuperInterface.java",
1255 "package $PackageName;
1256 public interface InterfaceRemovedSuperInterface extends BaseInterface {
1257 public Integer someMethod(Integer param);
1258 }");
1259
1260 # Interface_Removed_Super_Constant_Interface
1261 writeFile($Path_v1."/InterfaceRemovedSuperConstantInterface.java",
1262 "package $PackageName;
1263 public interface InterfaceRemovedSuperConstantInterface extends BaseInterface, BaseConstantInterface {
1264 public Integer someMethod(Integer param);
1265 }");
1266 writeFile($Path_v2."/InterfaceRemovedSuperConstantInterface.java",
1267 "package $PackageName;
1268 public interface InterfaceRemovedSuperConstantInterface extends BaseInterface {
1269 public Integer someMethod(Integer param);
1270 }");
1271
1272 # Interface_Became_Class
1273 writeFile($Path_v1."/InterfaceBecameClass.java",
1274 "package $PackageName;
1275 public interface InterfaceBecameClass extends BaseInterface, BaseInterface2 {
1276 public Integer someMethod(Integer param);
1277 }");
1278 writeFile($Path_v2."/InterfaceBecameClass.java",
1279 "package $PackageName;
1280 public class InterfaceBecameClass extends BaseClass {
1281 public Integer someMethod(Integer param) {
1282 return param;
1283 }
1284 }");
1285
1286 # Removed_Class
1287 writeFile($Path_v1."/RemovedClass.java",
1288 "package $PackageName;
1289 public class RemovedClass extends BaseClass {
1290 public Integer someMethod(Integer param){
1291 return param;
1292 }
1293 }");
1294
1295 # Removed_Class (w/o methods)
1296 writeFile($Path_v1."/RemovedFieldClass.java",
1297 "package $PackageName;
1298 public class RemovedFieldClass {
1299 public Integer field;
1300 }");
1301
1302 writeFile($TestsPath."/Test_RemovedFieldClass.java",
1303 "import $PackageName.*;
1304 public class Test_RemovedFieldClass
1305 {
1306 public static void main(String[] args)
1307 {
1308 RemovedFieldClass X = new RemovedFieldClass();
1309 Integer Copy = X.field;
1310 }
1311 }");
1312
1313 # Removed_Class (with static fields, private constructor)
1314 writeFile($Path_v1."/RemovedClassWithStaticField.java",
1315 "package $PackageName;
1316 public class RemovedClassWithStaticField
1317 {
1318 private RemovedClassWithStaticField(){}
1319 public static Integer cnt = 0;
1320 }");
1321
1322 writeFile($TestsPath."/Test_RemovedClassWithStaticField.java",
1323 "import $PackageName.*;
1324 public class Test_RemovedClassWithStaticField
1325 {
1326 public static void main(String[] args)
1327 {
1328 Integer Copy = RemovedClassWithStaticField.cnt;
1329 }
1330 }");
1331
1332 # Removed_Field (static field, private constructor)
1333 writeFile($Path_v1."/RemovedStaticFieldFromClassWithPrivateCtor.java",
1334 "package $PackageName;
1335 public class RemovedStaticFieldFromClassWithPrivateCtor
1336 {
1337 private RemovedStaticFieldFromClassWithPrivateCtor(){}
1338 public static Integer cnt = 0;
1339 }");
1340
1341 writeFile($Path_v2."/RemovedStaticFieldFromClassWithPrivateCtor.java",
1342 "package $PackageName;
1343 public class RemovedStaticFieldFromClassWithPrivateCtor
1344 {
1345 private RemovedStaticFieldFromClassWithPrivateCtor(){}
1346 }");
1347
1348 writeFile($TestsPath."/Test_RemovedStaticFieldFromClassWithPrivateCtor.java",
1349 "import $PackageName.*;
1350 public class Test_RemovedStaticFieldFromClassWithPrivateCtor
1351 {
1352 public static void main(String[] args)
1353 {
1354 Integer Copy = RemovedStaticFieldFromClassWithPrivateCtor.cnt;
1355 }
1356 }");
1357
1358 # Removed_Constant_Field
1359 writeFile($Path_v1."/ClassRemovedStaticConstantField.java",
1360 "package $PackageName;
1361 public class ClassRemovedStaticConstantField
1362 {
1363 public static int removedField_Int = 1000;
1364 public static String removedField_Str = \"Value\";
1365 }");
1366 writeFile($Path_v2."/ClassRemovedStaticConstantField.java",
1367 "package $PackageName;
1368 public class ClassRemovedStaticConstantField {
1369 }");
1370
1371 writeFile($TestsPath."/Test_ClassRemovedStaticConstantField.java",
1372 "import $PackageName.*;
1373 public class Test_ClassRemovedStaticConstantField
1374 {
1375 public static void main(String[] args)
1376 {
1377 Integer Copy = ClassRemovedStaticConstantField.removedField_Int;
1378 }
1379 }");
1380
1381 # Removed_Class (Deprecated)
1382 writeFile($Path_v1."/RemovedDeprecatedClass.java",
1383 "package $PackageName;
1384 \@Deprecated
1385 public class RemovedDeprecatedClass {
1386 public Integer someMethod(Integer param){
1387 return param;
1388 }
1389 }");
1390
1391 # Removed_Interface
1392 writeFile($Path_v1."/RemovedInterface.java",
1393 "package $PackageName;
1394 public interface RemovedInterface extends BaseInterface, BaseInterface2 {
1395 public Integer someMethod(Integer param);
1396 }");
1397
1398 # NonAbstract_Class_Added_Abstract_Method
1399 writeFile($Path_v1."/NonAbstractClassAddedAbstractMethod.java",
1400 "package $PackageName;
1401 public class NonAbstractClassAddedAbstractMethod {
1402 public Integer someMethod(Integer param1, String[] param2) {
1403 return param1;
1404 };
1405 }");
1406 writeFile($Path_v2."/NonAbstractClassAddedAbstractMethod.java",
1407 "package $PackageName;
1408 public abstract class NonAbstractClassAddedAbstractMethod {
1409 public Integer someMethod(Integer param1, String[] param2) {
1410 return param1;
1411 };
1412 public abstract Integer addedMethod(Integer param);
1413 }");
1414
1415 # Abstract_Class_Added_Abstract_Method
1416 writeFile($Path_v1."/AbstractClassAddedAbstractMethod.java",
1417 "package $PackageName;
1418 public abstract class AbstractClassAddedAbstractMethod {
1419 public Integer someMethod(Integer param1, String[] param2) {
1420 return param1;
1421 };
1422 }");
1423 writeFile($Path_v2."/AbstractClassAddedAbstractMethod.java",
1424 "package $PackageName;
1425 public abstract class AbstractClassAddedAbstractMethod {
1426 public Integer someMethod(Integer param1, String[] param2) {
1427 return param1;
1428 };
1429 public abstract Integer addedMethod(Integer param);
1430 }");
1431
1432 # Class_Became_Abstract
1433 writeFile($Path_v1."/ClassBecameAbstract.java",
1434 "package $PackageName;
1435 public class ClassBecameAbstract {
1436 public Integer someMethod(Integer param1, String[] param2) {
1437 return param1;
1438 };
1439 }");
1440 writeFile($Path_v2."/ClassBecameAbstract.java",
1441 "package $PackageName;
1442 public abstract class ClassBecameAbstract {
1443 public Integer someMethod(Integer param1, String[] param2) {
1444 return param1;
1445 };
1446 public abstract Integer addedMethod(Integer param);
1447 }");
1448
1449 # Class_Became_Final
1450 writeFile($Path_v1."/ClassBecameFinal.java",
1451 "package $PackageName;
1452 public class ClassBecameFinal {
1453 public Integer someMethod(Integer param1, String[] param2) {
1454 return param1;
1455 };
1456 }");
1457 writeFile($Path_v2."/ClassBecameFinal.java",
1458 "package $PackageName;
1459 public final class ClassBecameFinal {
1460 public Integer someMethod(Integer param1, String[] param2) {
1461 return param1;
1462 };
1463 }");
1464
1465 # Class_Removed_Abstract_Method
1466 writeFile($Path_v1."/ClassRemovedAbstractMethod.java",
1467 "package $PackageName;
1468 public abstract class ClassRemovedAbstractMethod {
1469 public Integer someMethod(Integer param1, String[] param2) {
1470 return param1;
1471 };
1472 public abstract void removedMethod(Integer param);
1473 }");
1474 writeFile($Path_v2."/ClassRemovedAbstractMethod.java",
1475 "package $PackageName;
1476 public abstract class ClassRemovedAbstractMethod {
1477 public Integer someMethod(Integer param1, String[] param2) {
1478 return param1;
1479 };
1480 }");
1481
1482 writeFile($TestsPath."/Test_ClassRemovedAbstractMethod.java",
1483 "import $PackageName.*;
1484 class ClassRemovedAbstractMethodDerived extends ClassRemovedAbstractMethod
1485 {
1486 public void removedMethod(Integer param) { }
1487 public static void main(String[] args) { }
1488 };
1489
1490 public class Test_ClassRemovedAbstractMethod
1491 {
1492 public static void main(String[] args)
1493 {
1494 ClassRemovedAbstractMethod Obj = new ClassRemovedAbstractMethodDerived();
1495 Obj.removedMethod(0);
1496 }
1497 }");
1498
1499 # Class_Method_Became_Abstract
1500 writeFile($Path_v1."/ClassMethodBecameAbstract.java",
1501 "package $PackageName;
1502 public abstract class ClassMethodBecameAbstract {
1503 public Integer someMethod(Integer param1, String[] param2) {
1504 return param1;
1505 };
1506 public Integer someMethod(Integer param){
1507 return param;
1508 };
1509 }");
1510 writeFile($Path_v2."/ClassMethodBecameAbstract.java",
1511 "package $PackageName;
1512 public abstract class ClassMethodBecameAbstract {
1513 public Integer someMethod(Integer param1, String[] param2) {
1514 return param1;
1515 };
1516 public abstract Integer someMethod(Integer param);
1517 }");
1518
1519 # Class_Method_Became_NonAbstract
1520 writeFile($Path_v1."/ClassMethodBecameNonAbstract.java",
1521 "package $PackageName;
1522 public abstract class ClassMethodBecameNonAbstract {
1523 public Integer someMethod(Integer param1, String[] param2) {
1524 return param1;
1525 };
1526 public abstract Integer someMethod(Integer param);
1527 }");
1528 writeFile($Path_v2."/ClassMethodBecameNonAbstract.java",
1529 "package $PackageName;
1530 public abstract class ClassMethodBecameNonAbstract {
1531 public Integer someMethod(Integer param1, String[] param2) {
1532 return param1;
1533 };
1534 public Integer someMethod(Integer param){
1535 return param;
1536 };
1537 }");
1538
1539 # Method_Became_Static
1540 writeFile($Path_v1."/MethodBecameStatic.java",
1541 "package $PackageName;
1542 public class MethodBecameStatic {
1543 public Integer someMethod(Integer param) {
1544 return param;
1545 };
1546 }");
1547 writeFile($Path_v2."/MethodBecameStatic.java",
1548 "package $PackageName;
1549 public class MethodBecameStatic {
1550 public static Integer someMethod(Integer param) {
1551 return param;
1552 };
1553 }");
1554
1555 # Method_Became_NonStatic
1556 writeFile($Path_v1."/MethodBecameNonStatic.java",
1557 "package $PackageName;
1558 public class MethodBecameNonStatic {
1559 public static Integer someMethod(Integer param) {
1560 return param;
1561 };
1562 }");
1563 writeFile($Path_v2."/MethodBecameNonStatic.java",
1564 "package $PackageName;
1565 public class MethodBecameNonStatic {
1566 public Integer someMethod(Integer param) {
1567 return param;
1568 };
1569 }");
1570
1571 # Static_Method_Became_Final
1572 writeFile($Path_v2."/StaticMethodBecameFinal.java",
1573 "package $PackageName;
1574 public class StaticMethodBecameFinal {
1575 public static Integer someMethod(Integer param) {
1576 return param;
1577 };
1578 }");
1579 writeFile($Path_v1."/StaticMethodBecameFinal.java",
1580 "package $PackageName;
1581 public class StaticMethodBecameFinal {
1582 public static final Integer someMethod(Integer param) {
1583 return param;
1584 };
1585 }");
1586
1587 writeFile($TestsPath."/Test_StaticMethodBecameFinal.java",
1588 "import $PackageName.*;
1589 public class Test_StaticMethodBecameFinal
1590 {
1591 public static void main(String[] args)
1592 {
1593 Integer R = StaticMethodBecameFinal.someMethod(0);
1594 }
1595 }");
1596
1597 # NonStatic_Method_Became_Final
1598 writeFile($Path_v1."/NonStaticMethodBecameFinal.java",
1599 "package $PackageName;
1600 public class NonStaticMethodBecameFinal {
1601 public Integer someMethod(Integer param) {
1602 return param;
1603 };
1604 }");
1605 writeFile($Path_v2."/NonStaticMethodBecameFinal.java",
1606 "package $PackageName;
1607 public class NonStaticMethodBecameFinal {
1608 public final Integer someMethod(Integer param) {
1609 return param;
1610 };
1611 }");
1612
1613 # Method_Became_Abstract
1614 writeFile($Path_v1."/MethodBecameAbstract.java",
1615 "package $PackageName;
1616 public abstract class MethodBecameAbstract {
1617 public Integer someMethod(Integer param) {
1618 return param;
1619 };
1620 }");
1621 writeFile($Path_v2."/MethodBecameAbstract.java",
1622 "package $PackageName;
1623 public abstract class MethodBecameAbstract {
1624 public abstract Integer someMethod(Integer param);
1625 }");
1626
1627 # Method_Became_NonAbstract
1628 writeFile($Path_v1."/MethodBecameNonAbstract.java",
1629 "package $PackageName;
1630 public abstract class MethodBecameNonAbstract {
1631 public abstract Integer someMethod(Integer param);
1632 }");
1633 writeFile($Path_v2."/MethodBecameNonAbstract.java",
1634 "package $PackageName;
1635 public abstract class MethodBecameNonAbstract {
1636 public Integer someMethod(Integer param) {
1637 return param;
1638 };
1639 }");
1640
1641 # Changed_Method_Access
1642 writeFile($Path_v1."/ChangedMethodAccess.java",
1643 "package $PackageName;
1644 public class ChangedMethodAccess {
1645 public Integer someMethod(Integer param) {
1646 return param;
1647 };
1648 }");
1649 writeFile($Path_v2."/ChangedMethodAccess.java",
1650 "package $PackageName;
1651 public class ChangedMethodAccess {
1652 protected Integer someMethod(Integer param) {
1653 return param;
1654 };
1655 }");
1656
1657 # Method_Became_Synchronized
1658 writeFile($Path_v1."/MethodBecameSynchronized.java",
1659 "package $PackageName;
1660 public class MethodBecameSynchronized {
1661 public Integer someMethod(Integer param) {
1662 return param;
1663 };
1664 }");
1665 writeFile($Path_v2."/MethodBecameSynchronized.java",
1666 "package $PackageName;
1667 public class MethodBecameSynchronized {
1668 public synchronized Integer someMethod(Integer param) {
1669 return param;
1670 };
1671 }");
1672
1673 # Method_Became_NonSynchronized
1674 writeFile($Path_v1."/MethodBecameNonSynchronized.java",
1675 "package $PackageName;
1676 public class MethodBecameNonSynchronized {
1677 public synchronized Integer someMethod(Integer param) {
1678 return param;
1679 };
1680 }");
1681 writeFile($Path_v2."/MethodBecameNonSynchronized.java",
1682 "package $PackageName;
1683 public class MethodBecameNonSynchronized {
1684 public Integer someMethod(Integer param) {
1685 return param;
1686 };
1687 }");
1688
1689 # Class_Overridden_Method
1690 writeFile($Path_v1."/OverriddenMethod.java",
1691 "package $PackageName;
1692 public class OverriddenMethod extends BaseClass {
1693 public Integer someMethod(Integer param) { return param; }
1694 }");
1695 writeFile($Path_v2."/OverriddenMethod.java",
1696 "package $PackageName;
1697 public class OverriddenMethod extends BaseClass {
1698 public Integer someMethod(Integer param) { return param; }
1699 public Integer method(Integer param) { return 2*param; }
1700 }");
1701
1702 # Class_Method_Moved_Up_Hierarchy
1703 writeFile($Path_v1."/ClassMethodMovedUpHierarchy.java",
1704 "package $PackageName;
1705 public class ClassMethodMovedUpHierarchy extends BaseClass {
1706 public Integer someMethod(Integer param) { return param; }
1707 public Integer method(Integer param) { return 2*param; }
1708 }");
1709 writeFile($Path_v2."/ClassMethodMovedUpHierarchy.java",
1710 "package $PackageName;
1711 public class ClassMethodMovedUpHierarchy extends BaseClass {
1712 public Integer someMethod(Integer param) { return param; }
1713 }");
1714
1715 # Class_Method_Moved_Up_Hierarchy (Interface Method) - should not be reported
1716 writeFile($Path_v1."/InterfaceMethodMovedUpHierarchy.java",
1717 "package $PackageName;
1718 public interface InterfaceMethodMovedUpHierarchy extends BaseInterface {
1719 public Integer method(Integer param);
1720 public Integer method2(Integer param);
1721 }");
1722 writeFile($Path_v2."/InterfaceMethodMovedUpHierarchy.java",
1723 "package $PackageName;
1724 public interface InterfaceMethodMovedUpHierarchy extends BaseInterface {
1725 public Integer method2(Integer param);
1726 }");
1727
1728 # Class_Method_Moved_Up_Hierarchy (Abstract Method) - should not be reported
1729 writeFile($Path_v1."/AbstractMethodMovedUpHierarchy.java",
1730 "package $PackageName;
1731 public abstract class AbstractMethodMovedUpHierarchy implements BaseInterface {
1732 public abstract Integer method(Integer param);
1733 public abstract Integer method2(Integer param);
1734 }");
1735 writeFile($Path_v2."/AbstractMethodMovedUpHierarchy.java",
1736 "package $PackageName;
1737 public abstract class AbstractMethodMovedUpHierarchy implements BaseInterface {
1738 public abstract Integer method2(Integer param);
1739 }");
1740
1741 # Use
1742 writeFile($Path_v1."/Use.java",
1743 "package $PackageName;
1744 public class Use
1745 {
1746 public FieldBecameFinal field;
1747 public void someMethod(FieldBecameFinal[] param) { };
1748 public void someMethod(Use param) { };
1749 public Integer someMethod(AbstractClassAddedSuperAbstractClass param) {
1750 return 0;
1751 }
1752 public Integer someMethod(AbstractClassAddedAbstractMethod param) {
1753 return 0;
1754 }
1755 public Integer someMethod(InterfaceAddedAbstractMethod param) {
1756 return 0;
1757 }
1758 public Integer someMethod(InterfaceAddedSuperInterface param) {
1759 return 0;
1760 }
1761 public Integer someMethod(AbstractClassAddedSuperInterface param) {
1762 return 0;
1763 }
1764 public Integer someMethod(AbstractClassAddedSuperInterfaceWithImplementedMethods param) {
1765 return 0;
1766 }
1767 public Integer someMethod(InterfaceRemovedLastAbstractMethod param) {
1768 return 0;
1769 }
1770
1771 }");
1772 writeFile($Path_v2."/Use.java",
1773 "package $PackageName;
1774 public class Use
1775 {
1776 public FieldBecameFinal field;
1777 public void someMethod(FieldBecameFinal[] param) { };
1778 public void someMethod(Use param) { };
1779 public Integer someMethod(AbstractClassAddedSuperAbstractClass param) {
1780 return param.abstractMethod(100)+param.field;
1781 }
1782 public Integer someMethod(AbstractClassAddedAbstractMethod param) {
1783 return param.addedMethod(100);
1784 }
1785 public Integer someMethod(InterfaceAddedAbstractMethod param) {
1786 return param.addedMethod(100);
1787 }
1788 public Integer someMethod(InterfaceAddedSuperInterface param) {
1789 return param.method2(100);
1790 }
1791 public Integer someMethod(AbstractClassAddedSuperInterface param) {
1792 return param.method2(100);
1793 }
1794 public Integer someMethod(AbstractClassAddedSuperInterfaceWithImplementedMethods param) {
1795 return param.method2(100);
1796 }
1797 public Integer someMethod(InterfaceRemovedLastAbstractMethod param) {
1798 return 0;
1799 }
1800 }");
1801
1802 # Added_Package
1803 writeFile($Path_v2."/AddedPackage/AddedPackageClass.java",
1804 "package $PackageName.AddedPackage;
1805 public class AddedPackageClass {
1806 public Integer field;
1807 public void someMethod(Integer param) { };
1808 }");
1809
1810 # Removed_Package
1811 writeFile($Path_v1."/RemovedPackage/RemovedPackageClass.java",
1812 "package $PackageName.RemovedPackage;
1813 public class RemovedPackageClass {
1814 public Integer field;
1815 public void someMethod(Integer param) { };
1816 }");
1817 my $BuildRoot1 = getDirname($Path_v1);
1818 my $BuildRoot2 = getDirname($Path_v2);
1819 if(compileJavaLib($LibName, $BuildRoot1, $BuildRoot2))
1820 {
1821 runTests($TestsPath, $PackageName, getAbsPath($BuildRoot1), getAbsPath($BuildRoot2));
1822 runChecker($LibName, $BuildRoot1, $BuildRoot2);
1823 }
1824}
1825
1826sub checkJavaCompiler($)
1827{ # check javac: compile simple program
1828 my $Cmd = $_[0];
1829
1830 if(not $Cmd) {
1831 return;
1832 }
1833
1834 my $TmpDir = $In::Opt{"Tmp"};
1835
1836 writeFile($TmpDir."/test_javac/Simple.java",
1837 "public class Simple {
1838 public Integer f;
1839 public void method(Integer p) { };
1840 }");
1841 chdir($TmpDir."/test_javac");
1842 system("$Cmd Simple.java 2>errors.txt");
1843 chdir($In::Opt{"OrigDir"});
1844 if($?)
1845 {
1846 my $Msg = "something is going wrong with the Java compiler (javac):\n";
1847 my $Err = readFile($TmpDir."/test_javac/errors.txt");
1848 $Msg .= $Err;
1849 if($Err=~/elf\/start\.S/ and $Err=~/undefined\s+reference\s+to/)
1850 { # /usr/lib/gcc/i586-suse-linux/4.5/../../../crt1.o: In function _start:
1851 # /usr/src/packages/BUILD/glibc-2.11.3/csu/../sysdeps/i386/elf/start.S:115: undefined reference to main
1852 $Msg .= "\nDid you install a JDK-devel package?";
1853 }
1854 exitStatus("Error", $Msg);
1855 }
1856}
1857
1858sub runTests($$$$)
1859{
1860 my ($TestsPath, $PackageName, $Path_v1, $Path_v2) = @_;
1861
1862 printMsg("INFO", "Running tests ...");
1863
1864 # compile with old version of package
1865 my $JavacCmd = getCmdPath("javac");
1866 if(not $JavacCmd) {
1867 exitStatus("Not_Found", "can't find \"javac\" compiler");
1868 }
1869
1870 my $JavaCmd = getCmdPath("java");
1871 if(not $JavaCmd) {
1872 exitStatus("Not_Found", "can't find \"java\" command");
1873 }
1874
1875 chdir($TestsPath);
1876 system($JavacCmd." -classpath \"".$Path_v1."\" -g *.java");
1877 chdir($In::Opt{"OrigDir"});
1878
1879 foreach my $TestSrc (cmdFind($TestsPath, "", "*\\.java"))
1880 { # remove test source
1881 unlink($TestSrc);
1882 }
1883
1884 my $TEST_REPORT = "";
1885
1886 foreach my $TestPath (cmdFind($TestsPath, "", "*\\.class", 1))
1887 { # run tests
1888 my $Name = getFilename($TestPath);
1889 $Name=~s/\.class\Z//g;
1890
1891 chdir($TestsPath);
1892 system($JavaCmd." -classpath \"".join_A($Path_v2, ".")."\" $Name >result.txt 2>&1");
1893 chdir($In::Opt{"OrigDir"});
1894
1895 my $Result = readFile($TestsPath."/result.txt");
1896 unlink($TestsPath."/result.txt");
1897 $TEST_REPORT .= "TEST CASE: $Name\n";
1898 if($Result) {
1899 $TEST_REPORT .= "RESULT: FAILED\n";
1900 $TEST_REPORT .= "OUTPUT:\n$Result\n";
1901 }
1902 else {
1903 $TEST_REPORT .= "RESULT: SUCCESS\n";
1904 }
1905 $TEST_REPORT .= "\n";
1906 }
1907
1908 my $Journal = $TestsPath."/Journal.txt";
1909 writeFile($Journal, $TEST_REPORT);
1910 printMsg("INFO", "See journal with test results: $Journal");
1911}
1912
1913sub compileJavaLib($$$)
1914{
1915 my ($LibName, $BuildRoot1, $BuildRoot2) = @_;
1916
1917 my $JavacCmd = getCmdPath("javac");
1918 if(not $JavacCmd) {
1919 exitStatus("Not_Found", "can't find \"javac\" compiler");
1920 }
1921
1922 checkJavaCompiler($JavacCmd);
1923
1924 my $JarCmd = getCmdPath("jar");
1925 if(not $JarCmd) {
1926 exitStatus("Not_Found", "can't find \"jar\" command");
1927 }
1928
1929 # space before value, new line
1930 writeFile("$BuildRoot1/MANIFEST.MF", "Implementation-Version: 1.0\n");
1931 writeFile("$BuildRoot2/MANIFEST.MF", "Implementation-Version: 2.0\n");
1932
1933 my (%SrcDir1, %SrcDir2) = ();
1934 foreach my $Path (cmdFind($BuildRoot1, "f", "*\\.java")) {
1935 $SrcDir1{getDirname($Path)} = 1;
1936 }
1937 foreach my $Path (cmdFind($BuildRoot2, "f", "*\\.java")) {
1938 $SrcDir2{getDirname($Path)} = 1;
1939 }
1940 # build classes v.1
1941 foreach my $Dir (keys(%SrcDir1))
1942 {
1943 chdir($Dir);
1944 system("$JavacCmd -g *.java");
1945 chdir($In::Opt{"OrigDir"});
1946 if($?) {
1947 exitStatus("Error", "can't compile classes v.1");
1948 }
1949 }
1950 # create java archive v.1
1951 chdir($BuildRoot1);
1952 system("$JarCmd -cmf MANIFEST.MF $LibName.jar TestPackage");
1953 chdir($In::Opt{"OrigDir"});
1954
1955 # build classes v.2
1956 foreach my $Dir (keys(%SrcDir2))
1957 {
1958 chdir($Dir);
1959 system("$JavacCmd -g *.java");
1960 chdir($In::Opt{"OrigDir"});
1961 if($?) {
1962 exitStatus("Error", "can't compile classes v.2");
1963 }
1964 }
1965 # create java archive v.2
1966 chdir($BuildRoot2);
1967 system("$JarCmd -cmf MANIFEST.MF $LibName.jar TestPackage");
1968 chdir($In::Opt{"OrigDir"});
1969
1970 foreach my $SrcPath (cmdFind($BuildRoot1, "", "*\\.java")) {
1971 unlink($SrcPath);
1972 }
1973 foreach my $SrcPath (cmdFind($BuildRoot2, "", "*\\.java")) {
1974 unlink($SrcPath);
1975 }
1976 return 1;
1977}
1978
1979sub runChecker($$$)
1980{
1981 my ($LibName, $Path1, $Path2) = @_;
1982
1983 writeFile("$LibName/v1.xml", "
1984 <version>
1985 1.0
1986 </version>
1987 <archives>
1988 ".getAbsPath($Path1)."
1989 </archives>\n");
1990
1991 writeFile("$LibName/v2.xml", "
1992 <version>
1993 2.0
1994 </version>
1995 <archives>
1996 ".getAbsPath($Path2)."
1997 </archives>\n");
1998
1999 my $Cmd = "perl $0 -l $LibName $LibName/v1.xml $LibName/v2.xml";
2000 if($In::Opt{"Quick"}) {
2001 $Cmd .= " -quick";
2002 }
2003 if(defined $In::Opt{"SkipDeprecated"}) {
2004 $Cmd .= " -skip-deprecated";
2005 }
2006 if(defined $In::Opt{"OldStyle"}) {
2007 $Cmd .= " -old-style";
2008 }
2009 if(my $JdkPath = $In::Opt{"JdkPath"}) {
2010 $Cmd .= " -jdk-path \"$JdkPath\"";
2011 }
2012
2013 my $TmpDir = $In::Opt{"Tmp"};
2014
2015 writeFile($TmpDir."/skip-annotations.list", "TestPackage.Beta");
2016 $Cmd .= " -skip-annotations-list ".$TmpDir."/skip-annotations.list";
2017 if($In::Opt{"Debug"})
2018 {
2019 $Cmd .= " -debug";
2020 printMsg("INFO", "Executing $Cmd");
2021 }
2022
2023 my $Report = "compat_reports/$LibName/1.0_to_2.0/compat_report.html";
2024
2025 if(-f $Report) {
2026 unlink($Report);
2027 }
2028
2029 system($Cmd);
2030
2031 if(not -f $Report) {
2032 exitStatus("Error", "analysis has failed");
2033 }
2034
2035 # Binary
2036 my $BReport = readAttributes($Report, 0);
2037 my $NProblems = $BReport->{"type_problems_high"}+$BReport->{"type_problems_medium"};
2038 $NProblems += $BReport->{"method_problems_high"}+$BReport->{"method_problems_medium"};
2039 $NProblems += $BReport->{"removed"};
2040
2041 # Source
2042 my $SReport = readAttributes($Report, 1);
2043 $NProblems += $SReport->{"type_problems_high"}+$SReport->{"type_problems_medium"};
2044 $NProblems += $SReport->{"method_problems_high"}+$SReport->{"method_problems_medium"};
2045 $NProblems += $SReport->{"removed"};
2046
2047 if($NProblems>=100) {
2048 printMsg("INFO", "Test result: SUCCESS ($NProblems breaks found)\n");
2049 }
2050 else {
2051 printMsg("ERROR", "Test result: FAILED ($NProblems breaks found)\n");
2052 }
2053}
2054
2055return 1;
Note: See TracBrowser for help on using the repository browser.