Skip to content

Commit

Permalink
External annotations: promote flag -Xexternal-annotation-file to -ext…
Browse files Browse the repository at this point in the history
…ernal-annotation-file.

	Change on 2019/06/19 by antoniocortes <antoniocortes@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=253989939
  • Loading branch information
antonio-cortes-perez committed Jun 21, 2019
1 parent 92cfd60 commit bc09c9b
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
Expand Up @@ -244,7 +244,7 @@ public static Options parse(String[] args) throws IOException {
}
} else if (arg.equals("--print-reference-graph")) {
options.printReferenceGraph = true;
} else if (arg.equals("-Xexternal-annotation-file")) {
} else if (arg.equals("-external-annotation-file")) {
if (++nArg == args.length) {
usage(arg + " requires an argument");
}
Expand Down
5 changes: 5 additions & 0 deletions doc/man/j2objc.1
Expand Up @@ -80,6 +80,11 @@ Translate Javadoc comments into Xcode-compatible comments.
.BI \-\-doc\-comment-warnings
Report warnings when translating Javadoc comments.
.TP
.BI \-external\-annotation\-file
Specify the most common annotations that affect
transpilation in a Java Annotation Index File
(format defined by the Checker Framework).
.TP
.BI \-g:none
Do not generate Java source debugging support
.TP
Expand Down
4 changes: 2 additions & 2 deletions jre_emul/Makefile
Expand Up @@ -39,8 +39,8 @@ TRANSLATE_JAVA_FULL = $(JAVA_TO_TRANSLATE)
TRANSLATE_JAVA_RELATIVE = $(JAVA_TO_TRANSLATE)
TRANSLATE_ARGS = -sourcepath $(JRE_SRC) \
$(J2OBJC_DEBUGFLAGS) -encoding UTF-8 --doc-comments -Xtranslate-bootclasspath \
--nullability -Xexternal-annotation-file $(ANDROID_ANNOTATIONS) \
-Xexternal-annotation-file $(J2OBJC_ANNOTATIONS)
--nullability -external-annotation-file $(ANDROID_ANNOTATIONS) \
-external-annotation-file $(J2OBJC_ANNOTATIONS)
ifndef JAVA_8
TRANSLATE_ARGS += --patch-module java.base=$(JRE_SRC)
endif
Expand Down
2 changes: 1 addition & 1 deletion jre_emul/java.mk
Expand Up @@ -113,5 +113,5 @@ java_sources_manifest: $(JAVA_SOURCES_MANIFEST)
find_cycles: cycle_finder_dist $(JAVA_SOURCES_MANIFEST)
$(DIST_DIR)/cycle_finder --patch-module java.base=$(JRE_SRC) \
-w cycle_whitelist.txt -s $(JAVA_SOURCES_MANIFEST) \
-Xexternal-annotation-file $(J2OBJC_ANNOTATIONS)
-external-annotation-file $(J2OBJC_ANNOTATIONS)

2 changes: 1 addition & 1 deletion jre_emul/tests.mk
Expand Up @@ -80,7 +80,7 @@ ifndef JAVA_8
TRANSLATE_ARGS += --patch-module java.base=$(TEST_SRC):$(GEN_JAVA_DIR)
endif
ifdef J2OBJC_JRE_STRIP_REFLECTION
TRANSLATE_ARGS += -Xexternal-annotation-file lite/ignore_tests.jaif
TRANSLATE_ARGS += -external-annotation-file lite/ignore_tests.jaif
endif
TRANSLATE_SOURCES = $(SUPPORT_SOURCES) $(TEST_SOURCES) $(SUITE_SOURCES) $(ALL_TESTS_CLASS).java
TRANSLATE_SOURCES_ARC = $(ARC_TEST_SOURCES) $(COPIED_ARC_TEST_SOURCES)
Expand Down
Expand Up @@ -502,7 +502,7 @@ private void processArg(Iterator<String> args) throws IOException {
emitKytheMappings = true;
} else if (arg.equals("-Xno-source-headers")) {
emitSourceHeaders = false;
} else if (arg.equals("-Xexternal-annotation-file")) {
} else if (arg.equals("-external-annotation-file")) {
addExternalAnnotationFile(getArgValue(args, arg));
} else if (arg.equals("--reserved-names")) {
NameTable.addReservedNames(getArgValue(args, arg));
Expand Down
Expand Up @@ -50,6 +50,9 @@ Other options:\n\
--dead-code-report <file> Specify a ProGuard usage report for dead code elimination.\n\
--doc-comments Translate Javadoc comments into Xcode-compatible comments.\n\
--doc-comment-warnings Report warnings when translating Javadoc comments.\n\
-external-annotation-file Specify the most common annotations that affect\
\n transpilation in a Java Annotation Index File\
\n (format defined by the Checker Framework).\n\
-g:none Do not generate Java source debugging support.\n\
-g:relative Generate Java source debugging support with relative paths.\n\
--generate-deprecated Generate deprecated attributes for deprecated methods,\
Expand Down
Expand Up @@ -350,4 +350,38 @@ public void testWeak() throws IOException {
assertTranslation(translation, "__unsafe_unretained JavaLangThread *t_;");
assertTranslation(translation, "t_ = otherT;");
}

public void testRetainedWith() throws IOException {
String source = "package p; "
+ "import com.google.j2objc.annotations.RetainedWith; "
+ "public class A { "
+ " private Object o; "
+ " public void setO(Object o) { this.o = o; } "
+ "}";
options.addExternalAnnotationFileContents(
"package com.google.j2objc.annotations: "
+ "annotation @RetainedWith: "
+ "package p: "
+ "class A: "
+ " field o: @RetainedWith ");
String translation = translateSourceFile(source, "p.A", "p/A.m");
assertTranslation(translation, "JreRetainedWithAssign");
assertTranslation(translation, "JreRetainedWithRelease");
}

public void testAutoreleasePool() throws IOException {
String source = "package p; "
+ "import com.google.j2objc.annotations.AutoreleasePool; "
+ "public class A { "
+ " public void test() {} "
+ "}";
options.addExternalAnnotationFileContents(
"package com.google.j2objc.annotations: "
+ "annotation @AutoreleasePool: "
+ "package p: "
+ "class A: "
+ " method test()V: @AutoreleasePool ");
String translation = translateSourceFile(source, "p.A", "p/A.m");
assertTranslation(translation, "@autoreleasepool");
}
}

0 comments on commit bc09c9b

Please sign in to comment.