Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 84932 Details for
Bug 97332
[compiler] Add support for classpath specified in manifest file inside a jar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
test cases (wip)
patch_97332_02_writing_tests.txt (text/plain), 13.20 KB, created by
Maxime Daniel
on 2007-12-11 01:40:29 EST
(
hide
)
Description:
test cases (wip)
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-12-11 01:40:29 EST
Size:
13.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.140 >diff -u -r1.140 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 30 Nov 2007 13:50:41 -0000 1.140 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 11 Dec 2007 06:33:20 -0000 >@@ -53,6 +53,101 @@ > return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5); > } > >+protected void tearDown() throws Exception { >+ disposeCascadedJars(); >+ super.tearDown(); >+} >+ >+// PREMATURE find a way to build the jars once for the whole suite >+private boolean cascadedJarsCreated; >+private String cascadedJarsDirectoryPath; >+private void createCascadedJars() { >+ if (!this.cascadedJarsCreated) { >+ this.cascadedJarsDirectoryPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString(); >+ if (!this.cascadedJarsDirectoryPath.endsWith(File.separator)) { >+ this.cascadedJarsDirectoryPath = this.cascadedJarsDirectoryPath + File.separator; >+ } >+ try { >+ Util.createJar( >+ new String[] { >+ "p/A.java", >+ "package p;\n" + >+ "public class A {\n" + >+ "}", >+ }, >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: lib2.jar\n", >+ }, >+ this.cascadedJarsDirectoryPath + "lib1.jar", >+ JavaCore.VERSION_1_4); >+ Util.createJar( >+ new String[] { >+ "p/B.java", >+ "package p;\n" + >+ "public class B {\n" + >+ "}", >+ "p/R.java", >+ "package p;\n" + >+ "public class R {\n" + >+ " public static final int R2 = 2;\n" + >+ "}", >+ }, >+ this.cascadedJarsDirectoryPath + "lib2.jar", >+ JavaCore.VERSION_1_4); >+ Util.createJar( >+ new String[] { >+ "p/C.java", >+ "package p;\n" + >+ "public class C {\n" + >+ "}", >+ "p/R.java", >+ "package p;\n" + >+ "public class R {\n" + >+ " public static final int R3 = 3;\n" + >+ "}", >+ }, >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: lib4.jar\n", >+ }, >+ this.cascadedJarsDirectoryPath + "lib3.jar", >+ JavaCore.VERSION_1_4); >+ Util.createJar( >+ new String[] { >+ "p/D.java", >+ "package p;\n" + >+ "public class D {\n" + >+ "}", >+ }, >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: lib1.jar lib3.jar\n", >+ }, >+ this.cascadedJarsDirectoryPath + "lib4.jar", >+ JavaCore.VERSION_1_4); >+ this.cascadedJarsCreated = true; >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+} >+private void disposeCascadedJars() { >+ if (this.cascadedJarsCreated) { >+ Util.delete(this.cascadedJarsDirectoryPath + "lib1.jar"); >+ Util.delete(this.cascadedJarsDirectoryPath + "lib2.jar"); >+ Util.delete(this.cascadedJarsDirectoryPath + "lib3.jar"); >+ Util.delete(this.cascadedJarsDirectoryPath + "lib4.jar"); >+ this.cascadedJarsCreated = false; >+ } >+} >+ > private String getLibraryClassesAsQuotedString() { > String[] paths = Util.getJavaClassLibs(); > StringBuffer buffer = new StringBuffer(); >@@ -7815,6 +7910,201 @@ > "1 problem (1 warning)", > true); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+// basic link: a jar only referenced in the manifest of the first one is found >+public void test214_jar_ref_in_jar(){ >+ createCascadedJars(); >+ this.runConformTest( >+ new String[] { >+ "src/p/X.java", >+ "package p;\n" + >+ "/** */\n" + >+ "public class X {\n" + >+ " A a;\n" + >+ " B b;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR >+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" >+ + " -1.5 -g -preserveAllLocals" >+ + " -proceedOnError -referenceInfo" >+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", >+ "", >+ "", >+ true); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+// basic link inactive before 1.5 >+// WORK - reconsider >+// may want to reconsider in favor of an >+// explicit option (that is, do not condition links by a source level) >+public void test215_jar_ref_in_jar(){ >+ createCascadedJars(); >+ this.runNegativeTest( >+ new String[] { >+ "src/p/X.java", >+ "package p;\n" + >+ "/** */\n" + >+ "public class X {\n" + >+ " A a;\n" + >+ " B b;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" >+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" >+ + " -1.4 -g -preserveAllLocals" >+ + " -proceedOnError -referenceInfo" >+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", >+ "", >+ "----------\n" + >+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + >+ " B b;\n" + >+ " ^\n" + >+ "B cannot be resolved to a type\n" + >+ "----------\n" + >+ "1 problem (1 error)", >+ true); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+// bootclasspath does not get expanded >+// WORK needs specific jars that replace the runtime >+public void _test216_jar_ref_in_jar(){ >+ createCascadedJars(); >+ this.runNegativeTest( >+ new String[] { >+ "src/p/X.java", >+ "package p;\n" + >+ "/** */\n" + >+ "public class X {\n" + >+ " A a;\n" + >+ " C c;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" >+ + " -bootclasspath " + getLibraryClassesAsQuotedString() >+ + File.pathSeparator + "\"" + OUTPUT_DIR + File.separator + this.cascadedJarsDirectoryPath + "lib1.jar\"" >+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" >+ + " -1.5 -g -preserveAllLocals" >+ + " -proceedOnError -referenceInfo" >+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", >+ "", >+ "----------\n" + >+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + >+ " C c;\n" + >+ " ^\n" + >+ "C cannot be resolved to a type\n" + >+ "----------\n" + >+ "1 problem (1 error)", >+ true); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+// links are followed recursively, eliminating dupes >+public void test217_jar_ref_in_jar(){ >+ createCascadedJars(); >+ this.runConformTest( >+ new String[] { >+ "src/p/X.java", >+ "package p;\n" + >+ "/** */\n" + >+ "public class X {\n" + >+ " A a;\n" + >+ " B b;\n" + >+ " C c;\n" + >+ " D d;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\"" // WORK SIMULATED SO FAR >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR >+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" >+ + " -1.5 -g -preserveAllLocals" >+ + " -proceedOnError -referenceInfo" >+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", >+ "", >+ "", >+ true); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+// at first level, this is depth first, masking tailing libs >+public void test218_jar_ref_in_jar(){ >+ createCascadedJars(); >+ this.runNegativeTest( >+ new String[] { >+ "src/p/X.java", >+ "package p;\n" + >+ "/** */\n" + >+ "public class X {\n" + >+ " int i = R.R2;\n" + >+ " int j = R.R3;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" >+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" >+ + " -1.5 -g -preserveAllLocals" >+ + " -proceedOnError -referenceInfo" >+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", >+ "", >+ "----------\n" + >+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + >+ " int j = R.R3;\n" + >+ " ^^^^\n" + >+ "R.R3 cannot be resolved\n" + >+ "----------\n" + >+ "1 problem (1 error)", >+ true); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+// checking whether it is depth first or width first using only links >+// depth first hypothesis >+public void testONLY_219_jar_ref_in_jar(){ >+ createCascadedJars(); >+ this.runNegativeTest( >+ new String[] { >+ "src/p/X.java", >+ "package p;\n" + >+ "/** */\n" + >+ "public class X {\n" + >+ " int i = R.R2;\n" + >+ " int j = R.R3;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\"" >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR >+ + " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" // WORK SIMULATED SO FAR >+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" >+ + " -1.5 -g -preserveAllLocals" >+ + " -proceedOnError -referenceInfo" >+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", >+ "", >+ "----------\n" + >+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + >+ " int j = R.R3;\n" + >+ " ^^^^\n" + >+ "R.R3 cannot be resolved\n" + >+ "----------\n" + >+ "1 problem (1 error)", >+ true); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars >+//tests we want: >+//- jars are added just after the containing jar; masks following jars >+// variations on paths (the path must be relative, use subdirectory, and .. syntax) >+// multiple entries on a single line in the manifest >+// repeated classpath lines in the manifest >+// more white space than needed >+// minimum white space >+//- extensions are not expanded (need more work for bootclasspath and this one) >+ > public static Class testClass() { > return BatchCompilerTest.class; > } >Index: src/org/eclipse/jdt/core/tests/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v >retrieving revision 1.59 >diff -u -r1.59 Util.java >--- src/org/eclipse/jdt/core/tests/util/Util.java 22 Oct 2007 13:43:38 -0000 1.59 >+++ src/org/eclipse/jdt/core/tests/util/Util.java 11 Dec 2007 06:33:20 -0000 >@@ -312,13 +312,24 @@ > } > } > public static void createJar(String[] pathsAndContents, Map options, String jarPath) throws IOException { >+ createJar(pathsAndContents, null, options, jarPath); >+} >+public static void createJar(String[] pathsAndContents, String[] extraPathsAndContents, Map options, String jarPath) throws IOException { > String classesPath = getOutputDirectory() + File.separator + "classes"; > File classesDir = new File(classesPath); > flushDirectoryContent(classesDir); > compile(pathsAndContents, options, classesPath); >+ for (int i = 0, l = extraPathsAndContents == null ? 0 : extraPathsAndContents.length; i < l; /* inc in loop */) { >+ File outputFile = new File(classesPath, extraPathsAndContents[i++]); >+ outputFile.getParentFile().mkdirs(); >+ Util.writeToFile(extraPathsAndContents[i++], outputFile.getAbsolutePath()); >+ } > zip(classesDir, jarPath); > } >-public static void createJar(String[] pathsAndContents, String jarPath, String compliance) throws IOException { >+public static void createJar(String[] javaPathsAndContents, String jarPath, String compliance) throws IOException { >+ createJar(javaPathsAndContents, null, jarPath, compliance); >+} >+public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String compliance) throws IOException { > Map options = new HashMap(); > options.put(CompilerOptions.OPTION_Compliance, compliance); > options.put(CompilerOptions.OPTION_Source, compliance); >@@ -331,7 +342,7 @@ > options.put(CompilerOptions.OPTION_ReportTypeParameterHiding, CompilerOptions.IGNORE); > options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); > options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >- createJar(pathsAndContents, options, jarPath); >+ createJar(javaPathsAndContents, extraPathsAndContents, options, jarPath); > } > public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException { > String sourcesPath = getOutputDirectory() + File.separator + "sources";
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 97332
:
84932
|
85181
|
86096
|
86646
|
92916