Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue# 175 - This code modifies package to avoid the problem described in the issue #176

Merged
merged 1 commit into from

2 participants

@sykesd

See issue #175

I think the code is ok, and certainly works for me. It you want, I could modify the code so that the renaming only takes place in JsonEncodeDecoderClassCreator, rather than in every sub-class of BaseSourceCreator. But it seems the other sub-classes would not be subject to the same problem.

@mkristian
Owner

sorry - this one slipped. is this still an open issue for you ? I guess so if I look at the patch - just to confirm.

@sykesd

No worries. Yes, this is still an issue for us. Would be great if you could merge this in.

@mkristian mkristian merged commit 824aa29 into resty-gwt:master
@mkristian
Owner

merged manually - thanx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2014
  1. @sykesd
This page is out of date. Refresh to see the latest.
View
22 restygwt/src/main/java/org/fusesource/restygwt/rebind/BaseSourceCreator.java
@@ -77,8 +77,8 @@ public BaseSourceCreator(final TreeLogger logger, GeneratorContext context, JCla
this.logger = logger;
this.context = context;
this.source = source;
- this.packageName = source.getPackage().getName();
-
+ this.packageName = getOpenPackageName( source.getPackage().getName() );
+
if(source instanceof JParameterizedType)
{
JParameterizedType ptype = (JParameterizedType)source;
@@ -106,6 +106,24 @@ private String getName( JClassType source ){
return source.getSimpleSourceName();
}
}
+
+ /**
+ * Some packages are protected such that any type we generate in that package can't subsequently be loaded
+ * because of a {@link SecurityException}, for example <code>java.</code> and <code>javax.</code> packages.
+ * <p>
+ * To workaround this issue we add a prefix onto such packages so that the generated code can be loaded
+ * later. The prefix added is <code>open.</code>
+ *
+ * @param name
+ * @return
+ */
+ private String getOpenPackageName(String name) {
+ if (name.startsWith("java.") || name.startsWith("javax.")) {
+ name = "open."+name;
+ }
+ return name;
+ }
+
protected PrintWriter writer() throws UnableToCompleteException {
HashSet<String> classes = getGeneratedClasses();
if (classes.contains(name)) {
Something went wrong with that request. Please try again.