@@ -98,7 +98,7 @@ public void buildExplodedModules() throws IOException {
9898
9999 // JDK-8166286 - jmod fails on symlink to directory
100100 @ Test
101- public void testSymlinks () throws IOException {
101+ public void testDirSymlinks () throws IOException {
102102 Path apaDir = EXPLODED_DIR .resolve ("apa" );
103103 Path classesDir = EXPLODED_DIR .resolve ("apa" ).resolve ("classes" );
104104 assertTrue (compileModule ("apa" , classesDir ));
@@ -110,6 +110,8 @@ public void testSymlinks() throws IOException {
110110 assertTrue (Files .exists (link ));
111111 } catch (IOException |UnsupportedOperationException uoe ) {
112112 // OS does not support symlinks. Nothing to test!
113+ System .out .println ("Creating symlink failed. Test passes vacuously." );
114+ uoe .printStackTrace ();
113115 return ;
114116 }
115117
@@ -119,6 +121,42 @@ public void testSymlinks() throws IOException {
119121 "--class-path" , classesDir .toString (),
120122 jmod .toString ())
121123 .assertSuccess ();
124+ Files .delete (jmod );
125+ }
126+
127+ // JDK-8267583 - jmod fails on symlink to class file
128+ @ Test
129+ public void testFileSymlinks () throws IOException {
130+ Path apaDir = EXPLODED_DIR .resolve ("apa" );
131+ Path classesDir = EXPLODED_DIR .resolve ("apa" ).resolve ("classes" );
132+ assertTrue (compileModule ("apa" , classesDir ));
133+
134+ Files .move (classesDir .resolve ("module-info.class" ),
135+ classesDir .resolve ("module-info.class1" ));
136+ Files .move (classesDir .resolve (Paths .get ("jdk" , "test" , "apa" , "Apa.class" )),
137+ classesDir .resolve ("Apa.class1" ));
138+ try {
139+ Path link = Files .createSymbolicLink (
140+ classesDir .resolve ("module-info.class" ),
141+ classesDir .resolve ("module-info.class1" ).toAbsolutePath ());
142+ assertTrue (Files .exists (link ));
143+ link = Files .createSymbolicLink (
144+ classesDir .resolve (Paths .get ("jdk" , "test" , "apa" , "Apa.class" )),
145+ classesDir .resolve ("Apa.class1" ).toAbsolutePath ());
146+ assertTrue (Files .exists (link ));
147+ } catch (IOException |UnsupportedOperationException uoe ) {
148+ // OS does not support symlinks. Nothing to test!
149+ System .out .println ("Creating symlinks failed. Test passes vacuously." );
150+ uoe .printStackTrace ();
151+ return ;
152+ }
153+
154+ Path jmod = MODS_DIR .resolve ("apa.jmod" );
155+ jmod ("create" ,
156+ "--class-path" , classesDir .toString (),
157+ jmod .toString ())
158+ .assertSuccess ();
159+ Files .delete (jmod );
122160 }
123161
124162 // JDK-8170618 - jmod should validate if any exported or open package is missing
0 commit comments