diff options
author | mikaelpeltier <mikaelpeltier@google.com> | 2014-05-20 14:59:23 +0200 |
---|---|---|
committer | mikaelpeltier <mikaelpeltier@google.com> | 2014-05-20 15:09:50 +0200 |
commit | 513fc66cc85f8c702f4f4fd18ac2c1f1126e8ca3 (patch) | |
tree | 00559b41abfe43f3b512b2f7e193e72f019569cd | |
parent | f83b63cb3e66d73d290ac27a76a0cfc40bf43dda (diff) | |
download | toolchain_jack-513fc66cc85f8c702f4f4fd18ac2c1f1126e8ca3.zip toolchain_jack-513fc66cc85f8c702f4f4fd18ac2c1f1126e8ca3.tar.gz toolchain_jack-513fc66cc85f8c702f4f4fd18ac2c1f1126e8ca3.tar.bz2 |
Incremental support, add dependency on class literal usages
Change-Id: I29dd96935b4e8c3cfcf04ea52f6933359c096b89
3 files changed, 80 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 849c784..44d7ef6 100644 --- a/jack/src/com/android/jack/experimental/incremental/UsageFinder.java +++ b/jack/src/com/android/jack/experimental/incremental/UsageFinder.java @@ -20,6 +20,7 @@ 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.JClass; +import com.android.jack.ir.ast.JClassLiteral; import com.android.jack.ir.ast.JDefinedClass; import com.android.jack.ir.ast.JDefinedClassOrInterface; import com.android.jack.ir.ast.JDefinedInterface; @@ -116,6 +117,12 @@ public class UsageFinder implements RunnableSchedulable<JDefinedClassOrInterface } @Override + public boolean visit(@Nonnull JClassLiteral classLiteral) { + addCodeUsage(classLiteral.getRefType()); + return super.visit(classLiteral); + } + + @Override public boolean visit(@Nonnull JInstanceOf instanceofStmt) { addCodeUsage(instanceofStmt.getTestType()); return super.visit(instanceofStmt); diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest012.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest012.java new file mode 100644 index 0000000..02d7e01 --- /dev/null +++ b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest012.java @@ -0,0 +1,71 @@ +/* + * 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 DependenciesTest012 { + + @BeforeClass + public static void setUpClass() { + Main.class.getClassLoader().setDefaultAssertionStatus(true); + } + + /** + * Check that incremental compilation support class literal usages. + */ + @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 Class getClazz() { " + + " return B.class; " + + "} " + + "}"); + + 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.incrementalBuildFromFolder(); + Assert.fail(); + } catch (FrontendCompilationException e) { + // Ok + } + } +} + diff --git a/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java b/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java index 7fdc1b2..8aed15c 100644 --- a/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java +++ b/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java @@ -8,6 +8,7 @@ import org.junit.runners.Suite.SuiteClasses; @SuiteClasses(value = {DependenciesTest001.class, DependenciesTest002.class, DependenciesTest003.class, DependenciesTest004.class, DependenciesTest005.class, DependenciesTest006.class, DependenciesTest007.class, DependenciesTest008.class, - DependenciesTest009.class, DependenciesTest010.class, DependenciesTest011.class}) + DependenciesTest009.class, DependenciesTest010.class, DependenciesTest011.class, + DependenciesTest012.class}) public class DependencyAllTests { }
\ No newline at end of file |