This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
Fixed classpath issues with RoboGuice #1158
Merged
WonderCsabo
merged 1 commit into
androidannotations:develop
from
WonderCsabo:1116_fixRoboGuiceSupportV4Problem
Oct 12, 2014
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed classpath issues with RoboGuice
Some classes of RoboGuice are referencing the android.support package. This is problematic, since it is not always in the classpath. In that case, generated code cannot be compiled if support classes are indirectly referenced, also validation can go wrong. This commit fixes that issue by removing all indirect reference to the support package.
- Loading branch information
commit 574fd51661e10253d9c66fe8650b86dc9770d75a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...idannotations-api/src/main/java/org/androidannotations/api/roboguice/RoboGuiceHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.androidannotations.api.roboguice; | ||
|
|
||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
|
|
||
| /** | ||
| * Reflection utils to call methods which are accessible in RoboGuice package | ||
| * but not from outside. | ||
| */ | ||
| public class RoboGuiceHelper { | ||
|
|
||
| public static void callInjectViews(Object activity) { | ||
| try { | ||
| Class<?> viewMembersInjectorClass = Class.forName("roboguice.inject.ViewListener$ViewMembersInjector"); | ||
| Method injectViewsMethod = viewMembersInjectorClass.getDeclaredMethod("injectViews", Object.class); | ||
| injectViewsMethod.setAccessible(true); | ||
| injectViewsMethod.invoke(null, activity); | ||
| } catch (ClassNotFoundException e) { | ||
| propagateRuntimeException(e); | ||
| } catch (NoSuchMethodException e) { | ||
| propagateRuntimeException(e); | ||
| } catch (SecurityException e) { | ||
| propagateRuntimeException(e); | ||
| } catch (IllegalAccessException e) { | ||
| propagateRuntimeException(e); | ||
| } catch (IllegalArgumentException e) { | ||
| propagateRuntimeException(e); | ||
| } catch (InvocationTargetException e) { | ||
| propagateRuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| private static void propagateRuntimeException(Throwable t) { | ||
| throw new RuntimeException("Could not invoke RoboGuice method!", t); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you catch any
RuntimeExceptionin a singlecatch?It would enable us to remove the method
propagateRuntimeException.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like catching any exceptions, and it is a very bad design, since that means just consuming all
RuntimeExceptions, for example NPE, too. The current code is ugly, but would be much nicer if we would use Java 7, because we could just catchReflectiveOperationException.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Java 6 Supported or are we building for 7? Then you could go with Multi catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use Java 6, see the newest issue.