diff options
| author | Benoit Lamarche <benoitlamarche@google.com> | 2015-03-03 14:49:42 +0100 |
|---|---|---|
| committer | Benoit Lamarche <benoitlamarche@google.com> | 2015-03-03 14:49:42 +0100 |
| commit | 26bf7826306f25561e79c443e58c5bcf46d37ba4 (patch) | |
| tree | 0bd10fba25ec86c4eed03c1c84f5b890a0de27f7 /jack-api/src/com/android/jack/api | |
| parent | ec4c6ad6a11556b570a63367e8aa2d7726c618d2 (diff) | |
| download | toolchain_jack-26bf7826306f25561e79c443e58c5bcf46d37ba4.tar.gz toolchain_jack-26bf7826306f25561e79c443e58c5bcf46d37ba4.tar.bz2 toolchain_jack-26bf7826306f25561e79c443e58c5bcf46d37ba4.zip | |
Rename package api01 to api.v01
Change-Id: I8b9fdafeccb6ed04730581290a97a44c0e75bd89
Diffstat (limited to 'jack-api/src/com/android/jack/api')
13 files changed, 563 insertions, 5 deletions
diff --git a/jack-api/src/com/android/jack/api/example/Main.java b/jack-api/src/com/android/jack/api/example/Main.java index 51b74594..d8e4f3de 100644 --- a/jack-api/src/com/android/jack/api/example/Main.java +++ b/jack-api/src/com/android/jack/api/example/Main.java @@ -19,11 +19,11 @@ package com.android.jack.api.example; import com.android.jack.api.ConfigNotSupportedException; import com.android.jack.api.JackConfig; import com.android.jack.api.JackConfigProvider; -import com.android.jack.api01.AbortException; -import com.android.jack.api01.Api01Compiler; -import com.android.jack.api01.Api01Config; -import com.android.jack.api01.ConfigurationException; -import com.android.jack.api01.UnrecoverableException; +import com.android.jack.api.v01.AbortException; +import com.android.jack.api.v01.Api01Compiler; +import com.android.jack.api.v01.Api01Config; +import com.android.jack.api.v01.ConfigurationException; +import com.android.jack.api.v01.UnrecoverableException; import java.io.File; import java.lang.reflect.InvocationTargetException; diff --git a/jack-api/src/com/android/jack/api/v01/AbortException.java b/jack-api/src/com/android/jack/api/v01/AbortException.java new file mode 100644 index 00000000..70856b63 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/AbortException.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 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.api.v01; + +import javax.annotation.Nonnull; + +/** + * STOSHIP + */ +public class AbortException extends Exception { + private static final long serialVersionUID = 1L; + + public AbortException() { + super(); + } + + public AbortException(@Nonnull String message) { + super(message); + } + + public AbortException(@Nonnull String message, @Nonnull Throwable cause) { + super(message, cause); + } + + public AbortException(@Nonnull Throwable cause) { + super(cause); + } +} diff --git a/jack-api/src/com/android/jack/api/v01/Api01Compiler.java b/jack-api/src/com/android/jack/api/v01/Api01Compiler.java new file mode 100644 index 00000000..34ac6d37 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/Api01Compiler.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2015 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.api.v01; + + +/** + * STOPSHIP + */ +public interface Api01Compiler { + void run() throws AbortException, UnrecoverableException; +} diff --git a/jack-api/src/com/android/jack/api/v01/Api01Config.java b/jack-api/src/com/android/jack/api/v01/Api01Config.java new file mode 100644 index 00000000..dcab092b --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/Api01Config.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2015 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.api.v01; + +import com.android.jack.api.JackConfig; + +import java.io.File; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; + +/** + * STOPSHIP + */ +public interface Api01Config extends JackConfig { + + @Nonnull + void setReporter(@Nonnull ReporterKind reporterKind, @Nonnull OutputStream reporterStream) + throws ConfigurationException; + + @Nonnull + void setTypeImportCollisionPolicy(@Nonnull TypeCollisionPolicy typeImportCollisionPolicy) + throws ConfigurationException; + + @Nonnull + void setResourceImportCollisionPolicy( + @Nonnull ResourceCollisionPolicy resourceImportCollisionPolicy) throws ConfigurationException; + + @Nonnull + void setJavaSourceVersion(@Nonnull JavaSourceVersion javaSourceVersion) + throws ConfigurationException; + + @Nonnull + void setObfuscationMappingOutputFile(@Nonnull File obfuscationMappingOuputFile) + throws ConfigurationException; + + @Nonnull + void setClasspath(@Nonnull List<File> classpath) throws ConfigurationException; + + @Nonnull + void setImportedJackLibraryFiles(@Nonnull List<File> importedJackLibraryFiles) + throws ConfigurationException; + + @Nonnull + void setMetaDirs(@Nonnull List<File> metaDirs) throws ConfigurationException; + + @Nonnull + void setResourceDirs(@Nonnull List<File> resourceDirs) throws ConfigurationException; + + @Nonnull + void setIncrementalDir(@Nonnull File incrementalDir) throws ConfigurationException; + + @Nonnull + void setOutputDexDir(@Nonnull File outputDexDir) throws ConfigurationException; + + @Nonnull + void setOutputJackFile(@Nonnull File outputJackFile) throws ConfigurationException; + + @Nonnull + void setJarJarConfigFile(@Nonnull File jarjarConfigFile) throws ConfigurationException; + + @Nonnull + void setProguardConfigFiles(@Nonnull List<File> proguardConfigFiles) + throws ConfigurationException; + + @Nonnull + void setEmitDebug(boolean emitDebug) throws ConfigurationException; + + @Nonnull + void setMultiDexKind(@Nonnull MultiDexKind multiDexKind) throws ConfigurationException; + + @Nonnull + void setVerbosityLevel(@Nonnull VerbosityLevel verbosityLevel) throws ConfigurationException; + + @Nonnull + void setProcessorNames(@Nonnull List<String> processorNames) throws ConfigurationException; + + @Nonnull + void setProcessorPath(@Nonnull List<File> processorPath) throws ConfigurationException; + + @Nonnull + void setProcessorOptions(@Nonnull Map<String, String> processorOptions) + throws ConfigurationException; + + @Nonnull + void setSourceEntries(@Nonnull List<File> sourceEntries) throws ConfigurationException; + + @Nonnull + void setProperty(@Nonnull String key, @Nonnull String value) throws ConfigurationException; + + @Nonnull + Api01Compiler build() throws ConfigurationException; +} diff --git a/jack-api/src/com/android/jack/api/v01/ChainedException.java b/jack-api/src/com/android/jack/api/v01/ChainedException.java new file mode 100644 index 00000000..1efea167 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/ChainedException.java @@ -0,0 +1,152 @@ +/* + * 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.api.v01; + +import java.util.ArrayList; +import java.util.Iterator; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + +/** + * Abstract class to easily chain exceptions together. + * + * The exception can be managed like any other exception. In this case, the first one will be the + * only one used. + * + * Special management can use the {@link #iterator()} or the {@link #getNextException()} to browse + * all chained exceptions and dispatch them. + * + * See {@link ChainedExceptionBuilder} to build the chain of exceptions. + */ +public abstract class ChainedException extends Exception + implements Iterable<ChainedException> { + private static final long serialVersionUID = 1L; + + @Nonnull + private String message; + + @Nonnegative + private int count = 1; + + @Nonnull + private ChainedException tail = this; + + @CheckForNull + private ChainedException next = null; + + public ChainedException(@Nonnull String message) { + super(""); + this.message = message; + } + + public ChainedException(@Nonnull String message, @Nonnull Throwable cause) { + super("", cause); + this.message = message; + } + + public ChainedException(@Nonnull Throwable cause) { + super(cause); + this.message = cause.getMessage(); + } + + @Override + @Nonnull + public String getMessage() { + return message; + } + + @Override + @Nonnull + public String getLocalizedMessage() { + return message; + } + + public void setMessage(@Nonnull String message) { + this.message = message; + } + + @Nonnull + protected ChainedException putAsLastExceptionOf( + @CheckForNull ChainedException head) { + if (head == null) { + this.tail = this; + this.next = null; + this.count = 1; + + return this; + } else { + head.tail.next = this; + head.tail = this; + head.count++; + + return head; + } + } + + @CheckForNull + public ChainedException getNextException() { + return next; + } + + @Nonnegative + public int getNextExceptionCount() { + return count; + } + + @Override + @Nonnull + public Iterator<ChainedException> iterator() { + ArrayList<ChainedException> list = new ArrayList<ChainedException>(count); + + ChainedException exception = this; + do { + list.add(exception); + exception = exception.next; + } while (exception != null); + + return list.iterator(); + } + + /** + * Builder to construct a chain of exceptions. + */ + public static class ChainedExceptionBuilder<T extends ChainedException> { + @CheckForNull + private T head = null; + + @SuppressWarnings("unchecked") + public void appendException(@Nonnull T exceptions) { + for (ChainedException exception : exceptions) { + head = (T) exception.putAsLastExceptionOf(head); + } + } + + public void throwIfNecessary() throws T { + if (head != null) { + throw head; + } + } + + @Nonnull + public T getException() { + assert head != null; + return head; + } + } +} diff --git a/jack-api/src/com/android/jack/api/v01/ConfigurationException.java b/jack-api/src/com/android/jack/api/v01/ConfigurationException.java new file mode 100644 index 00000000..a0671534 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/ConfigurationException.java @@ -0,0 +1,38 @@ +/* + * 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.api.v01; + +import javax.annotation.Nonnull; + +/** + * All exceptions thrown from the configuration framework. + */ +public abstract class ConfigurationException extends ChainedException { + private static final long serialVersionUID = 1L; + + public ConfigurationException(@Nonnull String message) { + super(message); + } + + public ConfigurationException(@Nonnull String message, @Nonnull Throwable cause) { + super(message, cause); + } + + public ConfigurationException(@Nonnull Throwable cause) { + super(cause); + } +} diff --git a/jack-api/src/com/android/jack/api/v01/JavaSourceVersion.java b/jack-api/src/com/android/jack/api/v01/JavaSourceVersion.java new file mode 100644 index 00000000..c0f9dec0 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/JavaSourceVersion.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 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.api.v01; + +/** + * Supported Java source version. + */ +public enum JavaSourceVersion { + JAVA_3, JAVA_4, JAVA_5, JAVA_6, JAVA_7 +} diff --git a/jack-api/src/com/android/jack/api/v01/MultiDexKind.java b/jack-api/src/com/android/jack/api/v01/MultiDexKind.java new file mode 100644 index 00000000..8076fb0e --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/MultiDexKind.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 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.api.v01; + +/** + * Available mode for the multidex feature + */ +public enum MultiDexKind { + NONE, NATIVE, LEGACY +}
\ No newline at end of file diff --git a/jack-api/src/com/android/jack/api/v01/ReporterKind.java b/jack-api/src/com/android/jack/api/v01/ReporterKind.java new file mode 100644 index 00000000..5b544642 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/ReporterKind.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 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.api.v01; + +/** + * Available reporters. + */ +public enum ReporterKind { + DEFAULT, SDK +}
\ No newline at end of file diff --git a/jack-api/src/com/android/jack/api/v01/ResourceCollisionPolicy.java b/jack-api/src/com/android/jack/api/v01/ResourceCollisionPolicy.java new file mode 100644 index 00000000..4e5881ea --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/ResourceCollisionPolicy.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 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.api.v01; + +/** + * How to handle resource collisions. + */ +public enum ResourceCollisionPolicy { + KEEP_FIRST, FAIL +} diff --git a/jack-api/src/com/android/jack/api/v01/TypeCollisionPolicy.java b/jack-api/src/com/android/jack/api/v01/TypeCollisionPolicy.java new file mode 100644 index 00000000..dcefc062 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/TypeCollisionPolicy.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 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.api.v01; + +/** + * How to handle type collisions. + */ +public enum TypeCollisionPolicy { + KEEP_FIRST, FAIL +} diff --git a/jack-api/src/com/android/jack/api/v01/UnrecoverableException.java b/jack-api/src/com/android/jack/api/v01/UnrecoverableException.java new file mode 100644 index 00000000..631827f7 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/UnrecoverableException.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2015 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.api.v01; + +import javax.annotation.Nonnull; + +/** + * Thrown when a major problem occurred because of an event out of control (e.g. an external process + * remove a temporary file used by Jack). Handling this error should only be reporting to the user + * and maybe just retry exactly the same thing as the one that has thrown. + */ +public class UnrecoverableException extends Exception { + private static final long serialVersionUID = 1L; + + public UnrecoverableException() { + super(); + } + + public UnrecoverableException(@Nonnull String message) { + super(message); + } + + public UnrecoverableException(@Nonnull String message, @Nonnull Throwable cause) { + super(message, cause); + } + + public UnrecoverableException(@Nonnull Throwable cause) { + super(cause); + } +} diff --git a/jack-api/src/com/android/jack/api/v01/VerbosityLevel.java b/jack-api/src/com/android/jack/api/v01/VerbosityLevel.java new file mode 100644 index 00000000..6a887451 --- /dev/null +++ b/jack-api/src/com/android/jack/api/v01/VerbosityLevel.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2015 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.api.v01; + + +/** + * Jack verbosity level + */ +public enum VerbosityLevel { + ERROR, + WARNING, + INFO, + DEBUG +}
\ No newline at end of file |
