Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String.split/toUpperCase/toLowerCase/replaceAll do not work #266

Closed
ogrammer opened this issue Nov 5, 2019 · 4 comments
Closed

String.split/toUpperCase/toLowerCase/replaceAll do not work #266

ogrammer opened this issue Nov 5, 2019 · 4 comments
Assignees
Labels

Comments

@ogrammer
Copy link
Contributor

ogrammer commented Nov 5, 2019

EDIT: I found that this same error also affects toUpperCase and toLowerCase.
EDIT: I found that a similar error affects replaceAll

String string = "A;b;c";
String[] strings = string.split(";");
for (String s : strings) Console.console().log(s);
Console.console().log(string.toUpperCase());
Console.console().log(string.toLowerCase());

2019-11-04 compile-time error:

Caused by: java.lang.IllegalStateException: Don't know how to promote BOOLEAN to REFERENCE
        at de.mirkosertic.bytecoder.ssa.TypeRef$Native$4.eventuallyPromoteTo(TypeRef.java:91)
        at de.mirkosertic.bytecoder.ssa.Value.widestTypeOf(Value.java:103)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.newPHIFor(ParsingHelperCache.java:203)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.lambda$resolveInitialPHIStateForNode$3(ParsingHelperCache.java:161)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.newPHIFor(ParsingHelperCache.java:192)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.lambda$resolveInitialPHIStateForNode$3(ParsingHelperCache.java:161)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.NaiveProgramGenerator.initializeBlockWith(NaiveProgramGenerator.java:675)
        at de.mirkosertic.bytecoder.ssa.NaiveProgramGenerator.initializeBlock(NaiveProgramGenerator.java:379)
        at de.mirkosertic.bytecoder.ssa.NaiveProgramGenerator.generateFrom(NaiveProgramGenerator.java:268)
String string = "Hello, Earth";
Console.console().log(string.replaceAll("(Hello, )\\w+", "$1Mars"));
Caused by: java.lang.IllegalStateException: Don't know how to promote REFERENCE to BOOLEAN
        at de.mirkosertic.bytecoder.ssa.TypeRef$Native$9.eventuallyPromoteTo(TypeRef.java:170)
        at de.mirkosertic.bytecoder.ssa.Value.widestTypeOf(Value.java:103)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.newPHIFor(ParsingHelperCache.java:203)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.lambda$resolveInitialPHIStateForNode$1(ParsingHelperCache.java:128)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.newPHIFor(ParsingHelperCache.java:192)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.lambda$resolveInitialPHIStateForNode$3(ParsingHelperCache.java:161)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.requestValue(ParsingHelper.java:120)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.newPHIFor(ParsingHelperCache.java:192)
        at de.mirkosertic.bytecoder.ssa.ParsingHelperCache.lambda$resolveInitialPHIStateForNode$3(ParsingHelperCache.java:161)
        at de.mirkosertic.bytecoder.ssa.ParsingHelper.getLocalVariable(ParsingHelper.java:104)
        at de.mirkosertic.bytecoder.ssa.NaiveProgramGenerator.initializeBlockWith(NaiveProgramGenerator.java:675)
        at de.mirkosertic.bytecoder.ssa.NaiveProgramGenerator.initializeBlock(NaiveProgramGenerator.java:379)
        at de.mirkosertic.bytecoder.ssa.NaiveProgramGenerator.generateFrom(NaiveProgramGenerator.java:268)
(Click here) Leftover warnings from a debug?
Class.forName usage detected with unknown class name
Class sun.nio.cs.UTF_8 is used by reflection!
Class sun.nio.cs.UTF_8 is used by reflection!
Class sun.nio.cs.UTF_16 is used by reflection!
Class sun.nio.cs.ISO_8859_1 is used by reflection!
Class sun.nio.cs.UTF_8 is used by reflection!
Class sun.nio.cs.UTF_16 is used by reflection!
Class sun.nio.cs.ISO_8859_1 is used by reflection!
Class java.lang.CharacterDataLatin1 is used by reflection!
Class java.lang.CharacterData00 is used by reflection!
Class java.lang.CharacterData01 is used by reflection!
Class java.lang.CharacterData02 is used by reflection!
Class java.lang.CharacterData0E is used by reflection!
Class java.lang.CharacterDataPrivateUse is used by reflection!
Class java.lang.CharacterDataUndefined is used by reflection!
@ogrammer ogrammer changed the title String.split does not work String.split/toUpperCase/toLowerCase do not work Nov 5, 2019
@ogrammer ogrammer changed the title String.split/toUpperCase/toLowerCase do not work String.split/toUpperCase/toLowerCase/replaceAll do not work Nov 5, 2019
@mirkosertic
Copy link
Owner

I guess this is the root cause, and the wrapping exception message was
de.mirkosertic.bytecoder.ssa.ControlFlowProcessingException: Error processing CFG for sun/util/locale/provider/LocaleProviderAdapter.forType, right?

Its an exception handler with PHI values that cannot be resolved correctly. I thought I fixed that many moons ago, but here is another corner case I missed. It is damn hard to get JVM Exception handling right.

@mirkosertic
Copy link
Owner

About the Reflection API usages in the compiler log: is is not a warning or an error. It is meant to inform the user about certain Reflection API usages. The used classes are not automatically resolved, as some cases are not always needed, as seen by Latin1 Character encodings vs, whole UTF vs. generated code size.

@ogrammer
Copy link
Contributor Author

ogrammer commented Nov 6, 2019

Yes indeed that was the message, I thought it was unnecessary so I left it out. How about providing an option to disable to Reflection API usage logger? It's pretty unnecessary to me.

@mirkosertic
Copy link
Owner

Merged to master. All other RegEx related issues will be resolved by #269.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants