-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1531 from lukasj/backports
Backports from master to EE8
- Loading branch information
Showing
10 changed files
with
177 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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
74 changes: 74 additions & 0 deletions
74
...ntime/impl/src/test/java/com/sun/xml/bind/v2/runtime/reflect/opt/ForeignAccessorTest.java
This file contains 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,74 @@ | ||
/* | ||
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
package com.sun.xml.bind.v2.runtime.reflect.opt; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import com.sun.xml.bind.v2.bytecode.ClassTailor; | ||
import com.sun.xml.bind.v2.runtime.reflect.Accessor; | ||
import org.junit.Test; | ||
|
||
public class ForeignAccessorTest { | ||
|
||
/** | ||
* Foreign accessor shouldn't throw ClassCastException, just skip optimization. | ||
*/ | ||
@Test | ||
public void foreignAccessor() throws NoSuchFieldException{ | ||
String newClassName = EntityWithForeignAccessor.class.getName().replace('.','/') + "$JaxbAccessorF_author"; | ||
Class<?> foreignAccessor = AccessorInjector.prepare(EntityWithForeignAccessor.class, | ||
ClassTailor.toVMClassName(ForeignAccessorTest.FieldAccessor_Ref.class), | ||
newClassName); | ||
assertNotNull(foreignAccessor); | ||
|
||
Accessor<Object, Object> accessor = OptimizedAccessorFactory.get(EntityWithForeignAccessor.class.getDeclaredField("author")); | ||
assertNull(accessor); | ||
} | ||
|
||
@Test | ||
public void knownAccessor() throws NoSuchFieldException { | ||
Accessor<Object, Object> accessor = OptimizedAccessorFactory.get(EntityWithKnownAccessor.class.getDeclaredField("author")); | ||
assertNotNull(accessor); | ||
} | ||
|
||
@XmlRootElement | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
static class EntityWithKnownAccessor { | ||
String author; | ||
} | ||
|
||
@XmlRootElement | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
static class EntityWithForeignAccessor { | ||
String author; | ||
} | ||
|
||
/** | ||
* Test template doesn't extend accessor intentionally. | ||
*/ | ||
public static class FieldAccessor_Ref /*extends Accessor*/ { | ||
public FieldAccessor_Ref() { | ||
// super(Ref.class); | ||
} | ||
|
||
public Object get(Object bean) { | ||
return ((Bean)bean).f_ref; | ||
} | ||
|
||
public void set(Object bean, Object value) { | ||
((Bean)bean).f_ref = (Ref)value; | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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 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