Skip to content

Commit

Permalink
[MCOMPILER-485] Always use forward slash for internal package name
Browse files Browse the repository at this point in the history
Per JLS 4.2.1 if the file separator character is not a forward slash,
replace it
  • Loading branch information
dbwiddis committed Feb 15, 2022
1 parent 8cbfb2e commit 7c9f69f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1363,12 +1363,16 @@ private void createMissingPackageInfoClasses( CompilerConfiguration compilerConf
private byte[] generatePackage( CompilerConfiguration compilerConfiguration, String javaFile )
{
int version = getOpcode( compilerConfiguration );
String internalPackageName = javaFile.substring( 0, javaFile.length() - ".java".length() );
if ( File.separatorChar != '/' )
{
internalPackageName = internalPackageName.replace( File.separatorChar, '/' );
}
ClassWriter cw = new ClassWriter( 0 );
cw.visitSource( "package-info.java", null );
cw.visit( version,
Opcodes.ACC_SYNTHETIC | Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE,
javaFile.substring( 0, javaFile.length() - ".java".length() ),
null, "java/lang/Object", null );
internalPackageName, null, "java/lang/Object", null );
return cw.toByteArray();
}

Expand Down

0 comments on commit 7c9f69f

Please sign in to comment.