@@ -98,7 +98,7 @@ public void buildExplodedModules() throws IOException {
98
98
99
99
// JDK-8166286 - jmod fails on symlink to directory
100
100
@ Test
101
- public void testSymlinks () throws IOException {
101
+ public void testDirSymlinks () throws IOException {
102
102
Path apaDir = EXPLODED_DIR .resolve ("apa" );
103
103
Path classesDir = EXPLODED_DIR .resolve ("apa" ).resolve ("classes" );
104
104
assertTrue (compileModule ("apa" , classesDir ));
@@ -110,6 +110,8 @@ public void testSymlinks() throws IOException {
110
110
assertTrue (Files .exists (link ));
111
111
} catch (IOException |UnsupportedOperationException uoe ) {
112
112
// OS does not support symlinks. Nothing to test!
113
+ System .out .println ("Creating symlink failed. Test passes vacuously." );
114
+ uoe .printStackTrace ();
113
115
return ;
114
116
}
115
117
@@ -119,6 +121,42 @@ public void testSymlinks() throws IOException {
119
121
"--class-path" , classesDir .toString (),
120
122
jmod .toString ())
121
123
.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 );
122
160
}
123
161
124
162
// JDK-8170618 - jmod should validate if any exported or open package is missing
0 commit comments