View | Details | Raw Unified | Return to bug 545033
Collapse All | Expand All

(-)a/ajde.core/testdata/IgnoreJava9JarElements/.gitignore (+2 lines)
Added Link Here
1
.gradle
2
build
(-)a/ajde.core/testdata/IgnoreJava9JarElements/README (+2 lines)
Added Link Here
1
Generates a modular, multi-release JAR. To regenerate, run `gradle jar`. The output
2
is `build/libs/IgnoreJava9JarElements.jar`.
(-)a/ajde.core/testdata/IgnoreJava9JarElements/build.gradle (+54 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2019 Contributors
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
apply plugin: 'java-library'
10
11
if (!JavaVersion.current().isJava11Compatible()) {
12
   throw new GradleException("Run with with JDK 11 or newer.")
13
}
14
15
sourceSets {
16
   java11 {
17
      java {
18
       srcDirs = ['src/main/java11']
19
      }
20
   }
21
   moduleInfo {
22
      java {
23
         srcDirs = ['src/main/module-info']
24
      }
25
   }
26
}
27
28
compileJava {
29
   sourceCompatibility = 8
30
   targetCompatibility = 8
31
}
32
33
compileJava11Java {
34
   sourceCompatibility = 11
35
   targetCompatibility = 11
36
}
37
38
compileModuleInfoJava {
39
   sourceCompatibility = 11
40
   targetCompatibility = 11
41
}
42
43
jar {
44
   into('META-INF/versions/11') {
45
      from sourceSets.java11.output
46
   }
47
   into('') {
48
      from sourceSets.moduleInfo.output
49
   }
50
   manifest.attributes(
51
      'Multi-Release': 'true',
52
      'Main-Class': 'org.aspectj.JdkSpecific'
53
   )
54
}
(-)a/ajde.core/testdata/IgnoreJava9JarElements/src/main/java/org/aspectj/JdkSpecific.java (+15 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2019 Contributors
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.aspectj;
10
11
public class JdkSpecific {
12
     public static void main(String... args) {
13
         System.out.println("This is the Java 8 version of the class.");
14
     }
15
}
(-)a/ajde.core/testdata/IgnoreJava9JarElements/src/main/java11/org/aspectj/JdkSpecific.java (+15 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2019 Contributors
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.aspectj;
10
11
public class JdkSpecific {
12
     public static void main(String... args) {
13
         System.out.println("This is the Java 11 version of the class.");
14
     }
15
}
(-)a/ajde.core/testdata/IgnoreJava9JarElements/src/main/module-info/module-info.java (+11 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2019 Contributors
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
module org.aspectj.java9plusjar {
10
11
}
(-)a/ajde.core/testsrc/org/aspectj/ajde/core/tests/IgnoreJava9JarElements.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2019 Contributors
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
package org.aspectj.ajde.core.tests;
9
10
import java.io.File;
11
import java.io.IOException;
12
import java.util.Enumeration;
13
import java.util.HashSet;
14
import java.util.Set;
15
import java.util.jar.JarEntry;
16
import java.util.jar.JarFile;
17
import java.util.jar.Manifest;
18
19
import org.aspectj.ajde.core.AjdeCoreTestCase;
20
import org.aspectj.ajde.core.TestCompilerConfiguration;
21
import org.aspectj.ajde.core.TestMessageHandler;
22
23
public class IgnoreJava9JarElements extends AjdeCoreTestCase {
24
25
    public static final String injarName = "build/libs/IgnoreJava9JarElements.jar";
26
    public static final String outjarName = "outjar.jar";
27
28
    private TestMessageHandler handler;
29
    private TestCompilerConfiguration compilerConfig;
30
31
    protected void setUp() throws Exception {
32
        super.setUp();
33
        initialiseProject("IgnoreJava9JarElements");
34
        handler = (TestMessageHandler) getCompiler().getMessageHandler();
35
        compilerConfig = (TestCompilerConfiguration) getCompiler()
36
                .getCompilerConfiguration();
37
    }
38
39
    protected void tearDown() throws Exception {
40
        super.tearDown();
41
        handler = null;
42
        compilerConfig = null;
43
    }
44
45
    public void testWeave() {
46
        Set<File> injars = new HashSet<File>();
47
        injars.add(openFile(injarName));
48
        compilerConfig.setInpath(injars);
49
        Set<File> aspectpath = new HashSet<File>();
50
        compilerConfig.setAspectPath(aspectpath);
51
        File outjar = openFile(outjarName);
52
        compilerConfig.setOutjar(outjar.getAbsolutePath());
53
        doBuild(true);
54
        assertTrue("Expected no compiler errors or warnings but found "
55
                + handler.getMessages(), handler.getMessages().isEmpty());
56
        compareManifests(openFile(injarName), openFile(outjarName));
57
    }
58
59
    private void compareManifests(File inFile, File outFile) {
60
61
        try {
62
            JarFile inJar = new JarFile(inFile);
63
            Manifest inManifest = inJar.getManifest();
64
            inJar.close();
65
            JarFile outJar = new JarFile(outFile);
66
            Manifest outManifest = outJar.getManifest();
67
            outJar.close();
68
            assertTrue("The manifests in '" + inFile.getCanonicalPath()
69
                    + "' and '" + outFile.getCanonicalPath()
70
                    + "' sould be the same", inManifest.equals(outManifest));
71
        } catch (IOException ex) {
72
            fail(ex.toString());
73
        }
74
    }
75
76
}
(-)a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java (-2 / +10 lines)
Lines 391-405 public class BcelWeaver { Link Here
391
391
392
					while (entries.hasMoreElements()) {
392
					while (entries.hasMoreElements()) {
393
						JarEntry entry = (JarEntry) entries.nextElement();
393
						JarEntry entry = (JarEntry) entries.nextElement();
394
						String filename = entry.getName();
395
						String filenameLowercase = filename.toLowerCase();
396
397
						// Ignore class files that Java 8 won't understand (multi-release and module-info)
398
						if (filenameLowercase.startsWith("meta-inf")
399
								|| filenameLowercase.endsWith("module-info.class")) {
400
							continue;
401
						}
402
394
						InputStream inStream = inJar.getInputStream(entry);
403
						InputStream inStream = inJar.getInputStream(entry);
395
404
396
						byte[] bytes = FileUtil.readAsByteArray(inStream);
405
						byte[] bytes = FileUtil.readAsByteArray(inStream);
397
						String filename = entry.getName();
398
						// System.out.println("? addJarFile() filename='" + filename
406
						// System.out.println("? addJarFile() filename='" + filename
399
						// + "'");
407
						// + "'");
400
						UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);
408
						UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);
401
409
402
						if (filename.endsWith(".class")) {
410
						if (filenameLowercase.endsWith(".class")) {
403
							ReferenceType type = this.addClassFile(classFile, false);
411
							ReferenceType type = this.addClassFile(classFile, false);
404
							StringBuffer sb = new StringBuffer();
412
							StringBuffer sb = new StringBuffer();
405
							sb.append(inFile.getAbsolutePath());
413
							sb.append(inFile.getAbsolutePath());

Return to bug 545033