summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikaelpeltier <mikaelpeltier@google.com>2014-05-27 16:25:18 +0200
committermikaelpeltier <mikaelpeltier@google.com>2014-05-27 17:25:57 +0200
commit5e5b1876844b96fa51403ad9fc5de86cbfdb06dd (patch)
treef8489dea283ee1cb795cac27a68ac89b2a017282
parentd10ec24bf0fe4d2249b326b608da4888adfe27ff (diff)
downloadtoolchain_jack-5e5b1876844b96fa51403ad9fc5de86cbfdb06dd.zip
toolchain_jack-5e5b1876844b96fa51403ad9fc5de86cbfdb06dd.tar.gz
toolchain_jack-5e5b1876844b96fa51403ad9fc5de86cbfdb06dd.tar.bz2
Add dependencies through array in incremental support
Change-Id: Ib5485ecf702689a7bce5d157a533d289dfe5b496
-rw-r--r--jack/src/com/android/jack/experimental/incremental/UsageFinder.java4
-rw-r--r--jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java156
-rw-r--r--jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java2
3 files changed, 161 insertions, 1 deletions
diff --git a/jack/src/com/android/jack/experimental/incremental/UsageFinder.java b/jack/src/com/android/jack/experimental/incremental/UsageFinder.java
index 44d7ef6..5d35e1a 100644
--- a/jack/src/com/android/jack/experimental/incremental/UsageFinder.java
+++ b/jack/src/com/android/jack/experimental/incremental/UsageFinder.java
@@ -19,6 +19,7 @@ package com.android.jack.experimental.incremental;
import com.android.jack.ir.SourceOrigin;
import com.android.jack.ir.ast.HasType;
import com.android.jack.ir.ast.JArrayLiteral;
+import com.android.jack.ir.ast.JArrayType;
import com.android.jack.ir.ast.JClass;
import com.android.jack.ir.ast.JClassLiteral;
import com.android.jack.ir.ast.JDefinedClass;
@@ -76,6 +77,9 @@ public class UsageFinder implements RunnableSchedulable<JDefinedClassOrInterface
}
private void addCodeUsage(@Nonnull JType usedType) {
+ if (usedType instanceof JArrayType) {
+ usedType = ((JArrayType) usedType).getLeafType();
+ }
if (usedType.getSourceInfo() == SourceOrigin.UNKNOWN) {
return;
}
diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java
new file mode 100644
index 0000000..89e3a06
--- /dev/null
+++ b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.jack.experimental.incremental;
+
+import com.android.jack.Main;
+import com.android.jack.TestTools;
+import com.android.jack.frontend.FrontendCompilationException;
+
+import junit.framework.Assert;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JUnit test checking dependencies between Java files.
+ */
+public class DependenciesTest013 {
+
+ @BeforeClass
+ public static void setUpClass() {
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ /**
+ * Check that incremental compilation support array creation.
+ */
+ @Test
+ public void testDependency001() throws Exception {
+ IncrementalTestingEnvironment ite =
+ new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001"));
+
+ ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n"
+ + "public class A { \n"
+ + "public int getLength() { "
+ + " return new B[1].length; "
+ + "} "
+ + "}");
+
+ ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n"
+ + "public class B { \n"
+ + "}");
+
+ ite.incrementalBuildFromFolder();
+ ite.snapshotJackFilesModificationDate();
+ Assert.assertEquals(2, ite.getJackFiles().size());
+
+ ite.deleteJavaFile("jack.incremental", "B.java");
+
+ try {
+ ite.startErrRedirection();
+ ite.incrementalBuildFromFolder();
+ Assert.fail();
+ } catch (FrontendCompilationException e) {
+ // Ok
+ } finally {
+ Assert.assertTrue(ite.endErrorRedirection().contains("B cannot be resolved to a type"));
+ }
+ }
+
+ /**
+ * Check that incremental compilation support array usages.
+ */
+ @Test
+ public void testDependency002() throws Exception {
+ IncrementalTestingEnvironment ite =
+ new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001"));
+
+ ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n"
+ + "public class A { \n"
+ + "public int getLength() { "
+ + " return B.array.length; "
+ + "} "
+ + "}");
+
+ ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n"
+ + "public class B { \n"
+ + "public static C []array; \n"
+ + "}");
+
+ ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n"
+ + "public class C { \n"
+ + "}");
+
+ ite.incrementalBuildFromFolder();
+ ite.snapshotJackFilesModificationDate();
+ Assert.assertEquals(3, ite.getJackFiles().size());
+
+ ite.deleteJavaFile("jack.incremental", "C.java");
+
+ try {
+ ite.startErrRedirection();
+ ite.incrementalBuildFromFolder();
+ Assert.fail();
+ } catch (FrontendCompilationException e) {
+ // Ok
+ } finally {
+ Assert.assertTrue(ite.endErrorRedirection().contains("C cannot be resolved to a type"));
+ }
+ }
+
+ /**
+ * Check that incremental compilation support array usages.
+ */
+ @Test
+ public void testDependency003() throws Exception {
+ IncrementalTestingEnvironment ite =
+ new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001"));
+
+ ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n"
+ + "public class A { \n"
+ + "public int getLength() { "
+ + " return B.array.length; "
+ + "} "
+ + "}");
+
+ ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n"
+ + "public class B { \n"
+ + "public static C [][]array; \n"
+ + "}");
+
+ ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n"
+ + "public class C { \n"
+ + "}");
+
+ ite.incrementalBuildFromFolder();
+ ite.snapshotJackFilesModificationDate();
+ Assert.assertEquals(3, ite.getJackFiles().size());
+
+ ite.deleteJavaFile("jack.incremental", "C.java");
+
+ try {
+ ite.startErrRedirection();
+ ite.incrementalBuildFromFolder();
+ Assert.fail();
+ } catch (FrontendCompilationException e) {
+ // Ok
+ } finally {
+ Assert.assertTrue(ite.endErrorRedirection().contains("C cannot be resolved to a type"));
+ }
+ }
+}
+
diff --git a/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java b/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java
index 8aed15c..f0a1a61 100644
--- a/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java
+++ b/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java
@@ -9,6 +9,6 @@ import org.junit.runners.Suite.SuiteClasses;
DependenciesTest003.class, DependenciesTest004.class, DependenciesTest005.class,
DependenciesTest006.class, DependenciesTest007.class, DependenciesTest008.class,
DependenciesTest009.class, DependenciesTest010.class, DependenciesTest011.class,
- DependenciesTest012.class})
+ DependenciesTest012.class, DependenciesTest013.class})
public class DependencyAllTests {
} \ No newline at end of file