title: Why do I get this problem at runtime with the jre websphere instead with a normal jre 1.7 working properly?
body: <p>I am working with JPA and I have a table that repeats on n scheme. The query is written with jpql and I need to specify a different scheme based on the need to avoid creating duplicate code. More precisely I want to change the value of nameOfSchema of the annotation   <code>@Table (name = "nameofTable", schema = "nameofSchema")</code> 
  at runtime and then execute the query. In this regard I wrote the following method. While running with a normal JRE 1.7 it works correctly but when I run the method with websphere JRE 1.7 I get a runtime error.  </p>
  
  <pre><code>`public void changeTableSchema(final String schema,Class&lt;?&gt; entityWithTable) throws Exception {
      try {
          final String ANNOTATIONS = "annotations";
          Table anntotationToChange = entityWithTable.getAnnotation(Table.class);
          final Table anntotationToChangeCopy = anntotationToChange;
          anntotationToChange = new Table() {
              @Override
              public Class&lt;? extends Annotation&gt; annotationType() {
                  return anntotationToChangeCopy.annotationType();
              }
  
              @Override
              public UniqueConstraint[] uniqueConstraints() {
                  return anntotationToChangeCopy.uniqueConstraints();
              }
  
              @Override
              public String schema() {
                  return schema;
              }
  
              @Override
              public String name() {
                  return anntotationToChangeCopy.name();
              }
  
              @Override
              public String catalog() {
                  return anntotationToChangeCopy.catalog();
              }
          };
          Field annotations = Class.class.getDeclaredField(ANNOTATIONS);
          annotations.setAccessible(true);
          Map&lt;Class&lt;? extends Annotation&gt;, Annotation&gt; map = (Map&lt;Class&lt;? extends Annotation&gt;, Annotation&gt;) annotations
                  .get(entityWithTable.class);
          map.put(Table.class, anntotationToChange);
      } catch (Exception e) {
          e.printStackTrace();
      }
  } `
  </code></pre>
  
  <blockquote>
    <p>The error is:<br>
    java.lang.NoSuchFieldException:  annotations
      at java.lang.Class.getDeclaredFieldImpl(Native Method)
      at java.lang.Class.getDeclaredField(Class.java:720)
      at it.solarisistemi.awondo.be.web.Prova.changeTableSchema(Prova.java:106)
      at it.solarisistemi.awondo.be.web.Prova.main(Prova.java:23)</p>
  </blockquote>