private static final int java.util.BitSet.ADDRESS_BITS_PER_WORD错误不允许反射 [英] Reflection is not allowed on private static final int java.util.BitSet.ADDRESS_BITS_PER_WORD error

查看:112
本文介绍了private static final int java.util.BitSet.ADDRESS_BITS_PER_WORD错误不允许反射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用来自GAE的Gson访问数据时出现异常:
$ b

While I am accessing data using Gson from GAE getting exception:


异常:java.lang.SecurityException:
java .lang.IllegalAccessException:私有
上不允许反射。static final int java.util.BitSet.ADDRESS_BITS_PER_WORD

Exception:java.lang.SecurityException: java.lang.IllegalAccessException: Reflection is not allowed on private static final int java.util.BitSet.ADDRESS_BITS_PER_WORD

我的代码是:

Gson gson = new Gson();
JsonObject jsonObject = new JsonObject();
JsonElement element = gson.toJsonTree(dspinfo1);
JsonElement element1 = gson.toJsonTree(dspbh);
jsonObject.add("xxx", element1);
jsonObject.add("xxxx", element);
out.print(jsonObject.toString());

所以请给我建议,如果可能的话用示例。
complete ex是:

So please give me suggestion, if possible with example. complete ex is:

List<DSPMaster> dpsinfo1=new ArrayList<DSPMaster>(); 
DSPMaster dspinfo1 = dspDao.getdeliveryprovider(Long.parseLong(xxxx));
response.setContentType("text/html"); 
PrintWriter out = response.getWriter(); 
Gson gson = new Gson(); JsonObject jsonObject = new JsonObject(); 
JsonElement element = gson.toJsonTree(dspinfo1);
jsonObject.add("xxxx", element); 
out.print(jsonObject.toString());


推荐答案

您可以尝试Jackson类,将其转换为json架构和后来的预编译类。这将允许您绕过GAE中的反射问题。

You can try Jackson your class, convert it to json schema and later on pre-compile class. This will allow you to bypass reflection issue in GAE.

这篇关于private static final int java.util.BitSet.ADDRESS_BITS_PER_WORD错误不允许反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆