Keep only ASM 2.0 binary because it is still used in UnweavableTest
which uses an old ASM API, e.g. with a ClassWriter constructor which no
longer exists.
Also add JarJar 1.3 library because it is needed by an Ant task in
lib/asm/build.xml.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Simplify execution of PureJavaTests and KnownLimitationsTests
Getting rid of XML includes and two superfluous files, merging them with
their respective including counterparts. As far as I can see, the two
test suites are not part of the automatic build process, but can be
started manually as easily as any other test (suite) now.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Fix outdated ajcTestSuite.dtd and lots of XML problems
Now there should be no more inspection warnings when working with XML
test definitions. Only the strangely looking XML files used by
PureJavaTests and KnownLimitationsTests are left to be analysed and
fixed.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Make sure Java 14-only tests using preview are not executed on JVM 15+
Some Ajc196 tests are using preview features (see .../ajc196.xml), i.e.
they will fail on Java 15+ because code compiled with '--enable-preview'
can only run on the same JVM version, not on a more recent one. Hence,
the preview-using tests are now being excluded in order to make the
build run on Java 15, even though no Java 15 features are present in the
current 1.9.7 snapshot.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Move documentation generation into Maven profile 'create-docs'
The profile is active by default, but can be deactivated via
'-P !create-docs' on the Maven command line. This helps to speed up
'mvn install', maybe in combination with skipping tests, if we just want
to create a new set of AspectJ binaries.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Improve text matching in OutputSpec, fixing some failing Windows tests
Some Java 14 text block tests failed on Windows because a
StringTokenizer was used to split by LF, but the Windows line
separator is CR+LF. Because a multi-line string ending with CR+LF is
printed via 'System.out.println' in the test code, another CR+LF is
added to the output, resulting in trailing CR+LF+CR+LF. Hence, between
the two LFs, the tokenizer actually found an additional line consisting
of CR (only on Windows, of course). Despite each line token actually
containing a trailing CR token, that did not matter much because
'String.trim' was used everywhere before comparing values.
Anyway, the improved OutputSpec uses text.trim().split("\\s*\n\\s*"),
which takes care of leading/trailing whitespace both around the whole
output and for each separate line.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Make MoveInstructionsWeaveTestCase.testFancyHello pass when run twice
Reset counter, just in case this test runs multiple times in one JVM.
This can happen e.g. due to "run all tests" in IntelliJ IDEA, which
directly runs this test class and als WeaverModuleTests, both of which
implement junit.framework.TestCase. In that case, during the second run
the counter would start at a higher base count, making the 2nd test run
fail.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Make BCEL classpath utility recognise Java 15, fixing many tests
Inside org.aspectj.apache.bcel.util.ClassPath.getClassPath(), some JVM
version matching occurs which previously did not include Java 15.
Technically, AspectJ 1.9.6 does not support Java 15, but on GitHub
Actions there is a build job running on a JVM 15. This change should at
least make the weaver tests pass, making that test job more meaningful.
This fixes test errors like
java.lang.ClassCastException:
class org.aspectj.weaver.MissingResolvedTypeWithKnownSignature
cannot be cast to class
org.aspectj.weaver.ReferenceType
(org.aspectj.weaver.MissingResolvedTypeWithKnownSignature and
org.aspectj.weaver.ReferenceType are in unnamed module
of loader 'app')
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Fix: WeaveSpec no longer ignores the '-Xlintfile' parameter
Some tests in ajc150.xml and ajc190_from150.xml contain '<weave ...>'
build steps with 'xlintfile="..."' parameters. Those parameters were
passed through to Java and aspect code building steps, but not to the
final weaving step, sometimes leading to spurious "type not exposed to
weaver" warnings which occurred for some local and CI builds, but not
always. Very strange indeed. Anyway, by making method
WeaveSpec.buildWeaveArgs() pass on this parameter, the tests seem to run
reliably now.
TODO: Why does Ajc report that warning if the application JAR is on the
inpath and the aspect JAR is on the aspectpath? Is it because a marker
annotation is defined within the aspect JAR? But actually, that should
not matter, especially not work once and fail at other times. I guess
there is a class loading order problem or similar involved.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Add missing '-options' values -1.5, -1.9 to ajc{150,190_from150}.xml
When trying to find out why ajc150.xml and ajc190_from150.xml look
almost identical, I found out that only in many cases the 190 version
has '-option="1.9"' set where in the 150 version it was '-option="1.9"'.
Unfortunately, in both files source/target versions are not set at all
in many places, which looks unintentional. I tried to search & replace
all relevant '<compile ...>' commands for 190 first, then ported back to
150. Only cases in which clearly compiling to an older version like 1.3
or 1.4 is necessary were left like before.
I am expecting missing or false Java target versions in many other of
the legacy XML test suites. For now, I am just committing these two.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Set maven-assembly-plugin version 3.1.1 explicitly for each POM module
Background: There are CI tests failing because the version is not taken
from the parent POM, even if set in the 'pluginManagement' section.
Instead, it is resolved via the Maven Super POM, e.g. 2.2-beta-5, see:
https://maven.apache.org/ref/3.6.3/maven-model-builder/super-pom.html
That assembly plugin version in turn requires plexus-archiver
1.0-alpha-12. The latter cannot be downloaded from Maven Central,
leading to the problems seen during builds.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Replace path separators ';' by ',' in XML test specs
The goal is for them to be canonicalised to platform standard during
test execution. I am not sure if that will fix any tests, but at least I
hope it will not break any.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Replace directory separator '/' and surrogate path separator ',' by
platform-specific separators File.separatorChar and
File.pathSeparatorChar, respectively. Also make sure that replacement
occurs during write access, not read access. This was handled
differently in both sibling classes.
I am not sure if that helps to fix any Linux CI tests, but it is worth a
try.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Try to fix MultiProjectIncrementalTests.testAspectPath_pr265693
Check if path vs. package name discrepancy makes test fail on Linux. On
Windows it passes. So let's find out if file p/Asp.java vs. pkg.Asp
causes the problems.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
This made ModuleTests.testBuildModuleAndApplyAspectsFromAspectPath fail
because a file delete job for a module JAR failed after a previous
compile job had called FileUtil.isZipFile(File) in which the opened zip
file was never closed. A try with resources fixes that.
Maybe the corresponding test worked on Linux before, I did not try. I
just know that Linux is more forgiving about deleting open files while
on Windows they are being locked, which makes Windows the better system
to search for open file leaks.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
AjBuildManager: use try with resources in 2 places
I was debugging something in ModuleTests, trying to find out if there
are resource leaks. They were not in this class but in FileUtil - see
next commit. However, the little refactoring here does not hurt either.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Support Windows 10 and Windows Server 2016/2019 in installer
Those versions were not detected until now, which lead to bogus Windows
batch files forwarding only 9 Ajc parameters to the Java process via
"%1 %2 %3 %4 %5 %6 %7 %8 %9" instead of "%*".
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Lars Grefer [Sat, 15 Aug 2020 14:33:00 +0000 (16:33 +0200)]
Redundant Collection.addAll() call
Reports Collection.addAll() and Map.putAll() calls after instantiation of a collection using a constructor call without arguments. Such constructs can be replaced with a single call to a parametrized constructor which simplifies code. Also for some collections the replacement might be more performant.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Lars Grefer [Sat, 15 Aug 2020 14:30:09 +0000 (16:30 +0200)]
Collection.toArray() call style
There are two styles to convert a collection to an array: either using a pre-sized array (like c.toArray(new String[c.size()])) or using an empty array (like c.toArray(new String[0]).
In older Java versions using pre-sized array was recommended, as the reflection call which is necessary to create an array of proper size was quite slow. However since late updates of OpenJDK 6 this call was intrinsified, making the performance of the empty array version the same and sometimes even better, compared to the pre-sized version. Also passing pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the size and toArray call which may result in extra nulls at the end of the array, if the collection was concurrently shrunk during the operation.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Lars Grefer [Sat, 15 Aug 2020 14:25:42 +0000 (16:25 +0200)]
Single Map method can be used
Reports common usage patterns of java.util.Map that could be replaced with Java 8 methods: getOrDefault(), computeIfAbsent(), putIfAbsent(), merge(), or replaceAll().
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Lars Grefer [Sat, 15 Aug 2020 14:06:32 +0000 (16:06 +0200)]
Manual array to collection copy
Reports the copying of array contents to a collection where each element is added individually using a for loop. Such constructs may be replaced by a call to Collection.addAll(Arrays.asList()) or Collections.addAll().
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>