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

[jnigen] Fix summarizer encoding #1127

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions pkgs/jni/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.9.1-wip
## 0.9.1

- Fix compilation on macOS for consumers that don't use JNI on macOS (which is still not supported) ([#1122](https://github.com/dart-lang/native/pull/1122)).
- Fixed compilation on macOS for consumers that don't use JNI on macOS (which is
still not supported) ([#1122](https://github.com/dart-lang/native/pull/1122)).

## 0.9.0

Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: jni
description: A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen.
version: 0.9.1-wip
version: 0.9.1
repository: https://github.com/dart-lang/native/tree/main/pkgs/jni

topics:
Expand Down
6 changes: 6 additions & 0 deletions pkgs/jnigen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.9.1

- Fixed a bug in summarizer where standard output would use the default encoding
of the operating system and therefore breaking the UTF-8 decoding for some
locales.

## 0.9.0

- **Breaking Change** ([#660](https://github.com/dart-lang/native/issues/660)):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import com.github.dart_lang.jnigen.apisummarizer.util.InputStreamProvider;
import com.github.dart_lang.jnigen.apisummarizer.util.JsonWriter;
import com.github.dart_lang.jnigen.apisummarizer.util.StreamUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import javax.tools.DocumentationTool;
import javax.tools.JavaFileObject;
Expand Down Expand Up @@ -50,7 +48,7 @@ public static Map<String, ClassDecl> runDocletWithClass(
cli.addAll(List.of(options.toolArgs.split(" ")));
}

javaDoc.getTask(null, fileManager, System.err::println, docletClass, cli, fileObjects).call();
javaDoc.getTask(null, fileManager, stderr::println, docletClass, cli, fileObjects).call();

return SummarizerDoclet.getClasses();
}
Expand All @@ -60,12 +58,14 @@ public static Map<String, ClassDecl> runDoclet(
return runDocletWithClass(javaDoc, SummarizerDoclet.class, javaFileObjects, options);
}

static final PrintStream stderr = new PrintStream(System.err, true, StandardCharsets.UTF_8);

public static void main(String[] args) throws FileNotFoundException {
options = SummarizerOptions.parseArgs(args);
OutputStream output;

if (options.outputFile == null || options.outputFile.equals("-")) {
output = System.out;
output = new PrintStream(System.out, true, StandardCharsets.UTF_8);
} else {
output = new FileOutputStream(options.outputFile);
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public static void main(String[] args) throws FileNotFoundException {
}

if (!notFound.isEmpty()) {
System.err.println("Not found: " + notFound);
stderr.println("Not found: " + notFound);
System.exit(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public static SummarizerOptions parseArgs(String[] args) {
throw new ParseException("Need to specify the package or class names");
}
} catch (ParseException e) {
System.err.println(e.getMessage());
Main.stderr.println(e.getMessage());
help.printHelp(
new PrintWriter(System.err, true),
new PrintWriter(Main.stderr, true),
help.getWidth(),
"java -jar <JAR> [-s <SOURCE_DIR=.>] "
+ "[-c <CLASSES_JAR>] <CLASS_OR_PACKAGE_NAMES>\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@

package com.github.dart_lang.jnigen.apisummarizer.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

public class Log {
private static final Logger logger = Logger.getLogger("ApiSummarizer");

static {
try {
InputStream stream = Log.class.getResourceAsStream("/logging.properties");
LogManager.getLogManager().readConfiguration(stream);
LogManager.getLogManager().addLogger(logger);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

private static void log(Level level, String format, Object... args) {
String formatted = String.format(format, args);
logger.log(level, formatted);
Expand Down
6 changes: 6 additions & 0 deletions pkgs/jnigen/java/src/main/resources/logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
handlers = java.util.logging.ConsoleHandler

java.util.logging.FileHandler.encoding = UTF-8

.level = INFO

2 changes: 1 addition & 1 deletion pkgs/jnigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: jnigen
description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine.
version: 0.9.0
version: 0.9.1
repository: https://github.com/dart-lang/native/tree/main/pkgs/jnigen

environment:
Expand Down
Loading