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

Overload unimplemented getCharContent method #96

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jOOR-java-8/src/main/java/org/joor/Compile.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.util.*;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Map.Entry;
Expand Down Expand Up @@ -195,6 +196,11 @@ byte[] getBytes() {
public OutputStream openOutputStream() {
return os;
}

@Override
public CharSequence getCharContent(final boolean ignoreEncodingErrors) {
return new String(this.os.toByteArray(), Charset.forName("UTF-8"));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the encoding can be obtained somewhere else.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, Charset.forName("UTF-8") can be replaced with StandardCharsets.UTF_8.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@since 1.7

We still support Java 6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... not in that class, though. So yes, it could be replaced. Will do

}
}

static final class ClassFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
Expand Down