diff options
| author | Jean-Philippe Lesot <jplesot@google.com> | 2015-03-02 12:43:08 +0100 |
|---|---|---|
| committer | Jean-Philippe Lesot <jplesot@google.com> | 2015-03-02 12:43:08 +0100 |
| commit | 3f26d0f9cee0b5969c418058e4fdded4753cc9ae (patch) | |
| tree | f519d4f4cf7180407c8f90ca275d2b746f55e397 /jack-api/src/com/android/jack/api | |
| parent | 6afbe40f484e341672c00680fcb1a409250adbb5 (diff) | |
| download | toolchain_jack-3f26d0f9cee0b5969c418058e4fdded4753cc9ae.tar.gz toolchain_jack-3f26d0f9cee0b5969c418058e4fdded4753cc9ae.tar.bz2 toolchain_jack-3f26d0f9cee0b5969c418058e4fdded4753cc9ae.zip | |
Work on Jack API (WIP)
Change-Id: Ib2bc0e7dcddf34e8be1374c7ac67aaf7da6d5e17
Diffstat (limited to 'jack-api/src/com/android/jack/api')
7 files changed, 16 insertions, 363 deletions
diff --git a/jack-api/src/com/android/jack/api/brest/AbortException.java b/jack-api/src/com/android/jack/api/brest/AbortException.java deleted file mode 100644 index 05bd8ef9..00000000 --- a/jack-api/src/com/android/jack/api/brest/AbortException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.brest; - -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/brest/BrestCompiler.java b/jack-api/src/com/android/jack/api/brest/BrestCompiler.java deleted file mode 100644 index 111b5af2..00000000 --- a/jack-api/src/com/android/jack/api/brest/BrestCompiler.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.brest; - - -/** - * STOPSHIP - */ -public interface BrestCompiler { - void run() throws AbortException, UnrecoverableException; -} diff --git a/jack-api/src/com/android/jack/api/brest/BrestConfig.java b/jack-api/src/com/android/jack/api/brest/BrestConfig.java deleted file mode 100644 index e66db61c..00000000 --- a/jack-api/src/com/android/jack/api/brest/BrestConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.brest; - -import com.android.jack.api.JackConfig; - -import java.io.File; - -import javax.annotation.Nonnull; - -/** - * STOPSHIP - */ -public interface BrestConfig extends JackConfig { - @Nonnull - static final String PROPERTY_REPORTER = "jack.reporter"; - - @Nonnull - BrestConfig setOutputDex(@Nonnull File file) throws ConfigurationException; - - @Nonnull - BrestConfig setOutputJack(@Nonnull File file) throws ConfigurationException; - - @Nonnull - BrestConfig setConfigJarjar(@Nonnull File file) throws ConfigurationException; - - @Nonnull - BrestConfig setProperty(@Nonnull String key, @Nonnull String value) throws ConfigurationException; - - @Nonnull - BrestCompiler build() throws ConfigurationException; -} diff --git a/jack-api/src/com/android/jack/api/brest/ChainedException.java b/jack-api/src/com/android/jack/api/brest/ChainedException.java deleted file mode 100644 index 7a8a01cc..00000000 --- a/jack-api/src/com/android/jack/api/brest/ChainedException.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.brest; - -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/brest/ConfigurationException.java b/jack-api/src/com/android/jack/api/brest/ConfigurationException.java deleted file mode 100644 index ab98c679..00000000 --- a/jack-api/src/com/android/jack/api/brest/ConfigurationException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.brest; - -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/brest/UnrecoverableException.java b/jack-api/src/com/android/jack/api/brest/UnrecoverableException.java deleted file mode 100644 index 5d938faf..00000000 --- a/jack-api/src/com/android/jack/api/brest/UnrecoverableException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.brest; - -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/example/Main.java b/jack-api/src/com/android/jack/api/example/Main.java index 3215522d..be60cfa6 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.api.brest.AbortException; -import com.android.jack.api.brest.BrestCompiler; -import com.android.jack.api.brest.BrestConfig; -import com.android.jack.api.brest.ConfigurationException; -import com.android.jack.api.brest.UnrecoverableException; +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 java.io.File; import java.lang.reflect.InvocationTargetException; @@ -59,12 +59,12 @@ public class Main { } System.out.println(); - BrestCompiler brestCompiler; - BrestConfig brestConfig; + Api01Compiler api01Compiler; + Api01Config api01Config; // Get configuration object try { - brestConfig = confProvider.getConfig(BrestConfig.class); + api01Config = confProvider.getConfig(Api01Config.class); } catch (ConfigNotSupportedException e1) { System.err.println("Brest config not supported)"); return; @@ -73,14 +73,14 @@ public class Main { // Configure the compiler try { // Set standard options - brestConfig.setOutputDex(new File("out/")); - brestConfig.setConfigJarjar(new File("rules.jarjar")); + api01Config.setOutputDexFolder(new File("out/")); + api01Config.setConfigJarjarFile(new File("rules.jarjar")); // Set official properties - brestConfig.setProperty(BrestConfig.PROPERTY_REPORTER, "sdk"); - // Set provisioned properties - brestConfig.setProperty("jack.internal.test", "true"); + api01Config.setProperty(Api01Config.PROPERTY_REPORTER, "sdk"); + // Set provisional properties + api01Config.setProperty("jack.internal.test", "true"); // Check and build compiler - brestCompiler = brestConfig.build(); + api01Compiler = api01Config.build(); } catch (ConfigurationException e) { System.err.println(e.getMessage()); return; @@ -89,9 +89,9 @@ public class Main { // Run the compilation try { // First - brestCompiler.run(); + api01Compiler.run(); // Same compilation - brestCompiler.run(); + api01Compiler.run(); } catch (AbortException e) { System.out.println("User error, see reporter"); return; |
